Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB 6.0 >>> VB.NET / October 2006

Tip: Looking for answers? Try searching our database.

How to change type to structure?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
vb newbie - 09 Oct 2006 17:23 GMT
I'm trying to figure out how to use the FastFind API call w/in VP.NET.
One of the parameters passed to the API is (in part) something like the
type listed below.  How would you convert this into a Structure?

 Private Type WIN32_FIND_DATA
       cFileName As String * MAX_PATH
       Alternate As String * 14
 End Type

The problem as I understand it is that you can't define a fixed-length
character buffer within a structure. You could do something like this:

 Private Structure WIN32_FIND_DATA
       dim cFileName As String
       dim Alternate As String
 End Structure

But if you pass this to the API call, things don't work right.

I also tried:

Private Structure WIN32_FIND_DATA
       dim cFileName() as Byte
       dim Alternate() as Byte
End Structure

along with redim's of cFileName and Alternate, but that doesn't really
work either.

Any ideas on how to convert the data structure?
Mattias Sjögren - 09 Oct 2006 19:51 GMT
>Any ideas on how to convert the data structure?

Add the attribute <MarshalAs(UnmanagedType.ByValTStr,
SizeConst:=MAX_PATH)> to cFileName (when it's typed As String). The
attribute is located in the System.Runtime.InteropServices namespace.

Mattias

Signature

Mattias Sjögren [C# MVP]  mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

vb newbie - 10 Oct 2006 14:33 GMT
Thanks!
> >Any ideas on how to convert the data structure?
>
[quoted text clipped - 8 lines]
> http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
> Please reply only to the newsgroup.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.