When I use the CreateFile API function on my machine (win2000) it works perfectly, but when I create an installation and install it on another machine (win95), I am forever getting back -1.
Any ideas why it stops working?
Printable View
When I use the CreateFile API function on my machine (win2000) it works perfectly, but when I create an installation and install it on another machine (win95), I am forever getting back -1.
Any ideas why it stops working?
This page will tell you all about the CreateFile API.
http://www.vbapi.com/ref/c/createfile.html
It should work okay on Windows 95, so you might have to use the GetLastError Function to shed some light on the problem.
Good luck. :)
I read through the suggested page, and as far as I can make out my problem seems to be, I am passing in a Security Attribute structure for the lpSecurityAttributes parameter. This works fine on NT and 2000, but not on 95 and 98. For 95, 98 I need to pass in a 0 (byval clng(0)).
The thing is how can I tell what version of windows is running?
More so, if I try to put in a condition to pass in one parameter or the other, my code won't compile as 2000 doesn't like the passing of a 0.
Help please, I'm new to API and am getting tied in knots!!! :(
To get Version info of Windows put this code into a module:
Option Explicit
Declare Function GetVersionEx Lib "kernel32.dll" Alias "GetVersionExA" (lpVersionInformation As OSVERSIONINFO) As Long
Type OSVERSIONINFO
dwOSVersionInfoSize As Long
dwBuildNumber As Long
dwPlatformId As Long
szCSDVersion As String * 128
End Type
And put this in your form
Option Explicit
Private Sub Form_Load()
Dim os As OSVERSIONINFO ' receives version information
Dim retval As Long ' return value
os.dwOSVersionInfoSize = Len(os) ' set the size of the structure
retval = GetVersionEx(os) ' read Windows's version information
Select Case retval
Case 1
MsgBox "Win95/98"
Case 2
MsgBox "Win NT"
Case 0
MsgBox "Win 3.x"
End Select
End Sub
Retval returns the version of windows you have.
Hope this helps,
Hutchie
Excellent.
Thanks a lot. :)