Results 1 to 5 of 5

Thread: CreateFile

  1. #1

    Thread Starter
    Fanatic Member Stevie's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    565
    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?

  2. #2
    Lively Member Ishamel's Avatar
    Join Date
    Nov 1999
    Location
    Edinburgh, Scotland
    Posts
    112
    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.

  3. #3

    Thread Starter
    Fanatic Member Stevie's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    565
    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!!!

  4. #4
    Junior Member
    Join Date
    Feb 2000
    Location
    England
    Posts
    26
    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

  5. #5

    Thread Starter
    Fanatic Member Stevie's Avatar
    Join Date
    Mar 2000
    Location
    London, UK
    Posts
    565
    Excellent.

    Thanks a lot.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width