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.