Click here to Skip to main content
15,881,812 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: FindFirstFileEx() and Unicode Pin
treddie6-Jun-13 8:53
treddie6-Jun-13 8:53 
GeneralRe: FindFirstFileEx() and Unicode Pin
TnTinMn6-Jun-13 9:17
TnTinMn6-Jun-13 9:17 
GeneralRe: FindFirstFileEx() and Unicode Pin
treddie6-Jun-13 10:07
treddie6-Jun-13 10:07 
GeneralRe: FindFirstFileEx() and Unicode Pin
treddie6-Jun-13 14:29
treddie6-Jun-13 14:29 
GeneralRe: FindFirstFileEx() and Unicode Pin
TnTinMn6-Jun-13 15:06
TnTinMn6-Jun-13 15:06 
GeneralRe: FindFirstFileEx() and Unicode Pin
TnTinMn6-Jun-13 15:41
TnTinMn6-Jun-13 15:41 
GeneralRe: FindFirstFileEx() and Unicode Pin
treddie6-Jun-13 16:07
treddie6-Jun-13 16:07 
GeneralRe: FindFirstFileEx() and Unicode Pin
treddie6-Jun-13 18:04
treddie6-Jun-13 18:04 
So the problem WAS in my version of the WIN32_FIND_DATA structure.

I copied your declarations over to replace mine and other than having to provide something other than null for the initial values, nothing else was required. After doing that, my program works fine.

But I do not understand why my declarations were wrong.

-------------------------------------------------------------------------------------------------
Edit: vb had a banner over my function declaration that was telling me that I might have to martial the WIN32_FIND_DATA structure. I thought it was only referring to the two strings. But why was martialing required everywhere else?
-------------------------------------------------------------------------------------------------

The last two for the strings were what vb.Net suggested when I originally converted my vb6 program over to net, which apparently, in this case, were not the correct solutions. For the other declarations, FILETIME did not work, and the one that bothers me the worst is that Uint32 did not work. Isn't U4 (Unsigned 4 bytes) the same in principal as Uint32 (Unsigned 4 bytes)?

My old structure:
VB
Private Structure WIN32_FIND_DATA
  Dim dwFileAttributes As UInt32
  Dim ftCreationTime As FILETIME
  Dim ftLastAccessTime As FILETIME
  Dim ftLastWriteTime As FILETIME
  Dim nFileSizeHigh As UInt32
  Dim nFileSizeLow As UInt32
  Dim dwReserved0 As UInt32
  Dim dwReserved1 As UInt32

  <VBFixedString(MAX_PATH), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=MAX_PATH)> Public cFileName As String
  <VBFixedString(14), MarshalAs(UnmanagedType.ByValTStr, SizeConst:=14)> Public cAlternate As String

End Structure


Your structure:
VB
<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Unicode), BestFitMapping(False)> _
Private Class WIN32_FIND_DATA
   <MarshalAs(UnmanagedType.U4)> Public dwFileAttributes As IO.FileAttributes = 8208
   <MarshalAs(UnmanagedType.U4)> Private ftCreationTime_dwLowDateTime As UInt32 = 0
   <MarshalAs(UnmanagedType.U4)> Private ftCreationTime_dwHighDateTime As UInt32 = 0
   <MarshalAs(UnmanagedType.U4)> Private ftLastAccessTime_dwLowDateTime As UInt32 = 0
   <MarshalAs(UnmanagedType.U4)> Private ftLastAccessTime_dwHighDateTime As UInt32 = 0
   <MarshalAs(UnmanagedType.U4)> Private ftLastWriteTime_dwLowDateTime As UInt32 = 0
   <MarshalAs(UnmanagedType.U4)> Private ftLastWriteTime_dwHighDateTime As UInt32 = 0
   <MarshalAs(UnmanagedType.U4)> Public nFileSizeHigh As UInt32 = 0
   <MarshalAs(UnmanagedType.U4)> Public nFileSizeLow As UInt32 = 0
   <MarshalAs(UnmanagedType.U4)> Public dwReserved0 As UInt32 = 0
   <MarshalAs(UnmanagedType.U4)> Public dwReserved1 As UInt32 = 0

   ' Note: by changing the cFileName size constant from 260 to 32767 to handle long
   ' path names, it appears that cAlternateFileName always returns blank
   ' if the ShortPathName is needed, then use the GetShortPathName function
   ' http://msdn.microsoft.com/en-us/library/windows/desktop/aa364989%28v=vs.85%29.aspx
   <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=32767)> Public cFileName As String = " "
   <MarshalAs(UnmanagedType.ByValTStr, SizeConst:=14)> Public cAlternateFileName As String = " "


modified 7-Jun-13 2:52am.

GeneralRe: FindFirstFileEx() and Unicode Pin
treddie10-Jun-13 10:02
treddie10-Jun-13 10:02 
GeneralRe: FindFirstFileEx() and Unicode Pin
TnTinMn10-Jun-13 14:44
TnTinMn10-Jun-13 14:44 
GeneralRe: FindFirstFileEx() and Unicode Pin
treddie10-Jun-13 16:45
treddie10-Jun-13 16:45 
GeneralRe: FindFirstFileEx() and Unicode Pin
TnTinMn10-Jun-13 17:18
TnTinMn10-Jun-13 17:18 
GeneralRe: FindFirstFileEx() and Unicode Pin
treddie10-Jun-13 18:30
treddie10-Jun-13 18:30 
AnswerRe: FindFirstFileEx() and Unicode Pin
treddie11-Jun-13 13:22
treddie11-Jun-13 13:22 
QuestionApplication with calendar menu Pin
n3814-Jun-13 3:26
n3814-Jun-13 3:26 
AnswerRe: Application with calendar menu Pin
Dave Kreskowiak4-Jun-13 5:42
mveDave Kreskowiak4-Jun-13 5:42 
GeneralRe: Application with calendar menu Pin
n3814-Jun-13 6:24
n3814-Jun-13 6:24 
GeneralRe: Application with calendar menu Pin
Dave Kreskowiak4-Jun-13 10:33
mveDave Kreskowiak4-Jun-13 10:33 
GeneralRe: Application with calendar menu Pin
n3814-Jun-13 10:53
n3814-Jun-13 10:53 
GeneralRe: Application with calendar menu Pin
Dave Kreskowiak4-Jun-13 11:01
mveDave Kreskowiak4-Jun-13 11:01 
GeneralRe: Application with calendar menu Pin
n3814-Jun-13 12:10
n3814-Jun-13 12:10 
GeneralRe: Application with calendar menu Pin
Edward Giles25-Jun-13 23:00
Edward Giles25-Jun-13 23:00 
GeneralRe: Application with calendar menu Pin
n38126-Jun-13 3:11
n38126-Jun-13 3:11 
QuestionHow to insert all characters in database Pin
Beiniam3-Jun-13 21:05
Beiniam3-Jun-13 21:05 
AnswerRe: How to insert all characters in database Pin
Bernhard Hiller3-Jun-13 21:22
Bernhard Hiller3-Jun-13 21:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.