lina10
asked on
Access2.0, WIN95, API-GetDriveType doesn't work?
Hi! I have an access2.0 application(which was created under win 3.11) running on PC with WIN95.
i need to expand this app and,as a part of this process I have to be able to find which Drive is the CD_ROM Drive.
GetDriveType() function doesn't work-I get a "file not found" error message.
i checked it in access8 and it works OK.
But i need it to work in acc2.0.
Thank you
i need to expand this app and,as a part of this process I have to be able to find which Drive is the CD_ROM Drive.
GetDriveType() function doesn't work-I get a "file not found" error message.
i checked it in access8 and it works OK.
But i need it to work in acc2.0.
Thank you
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
HI Lina10,
Whats the main exercise, to get the API function working or to detect the CD-ROM drive.
Havent worried at this stage about determining whether drive is CDROM.
What info does the win3.11 API function return;what do you mean by 'doesnt return a cd-rom drive'.
Can you load kernell.dll into win95 system directory, run your program and hope for the best. :).
Whats the main exercise, to get the API function working or to detect the CD-ROM drive.
Havent worried at this stage about determining whether drive is CDROM.
What info does the win3.11 API function return;what do you mean by 'doesnt return a cd-rom drive'.
Can you load kernell.dll into win95 system directory, run your program and hope for the best. :).
ASKER
Hello,ozphil!
i got an email notification that you have added a comment
but it doesn't appear on question history.I hope you saw
my comment on your answer.What is going on?
lina10
i got an email notification that you have added a comment
but it doesn't appear on question history.I hope you saw
my comment on your answer.What is going on?
lina10
ASKER
Hello again!
please disregard my last comment!(after i submitted it,the history
was presented in full)
i checked under win3.11 api text viewer and this function returnes only tree values and none of them CD_ROM!
while the kernel32 function returnes 5 values,including cd_rom.
Now,about copying kernell to my system:Is there any point to it,if it doesn't return a cd_rom? What to do?
thank you
please disregard my last comment!(after i submitted it,the history
was presented in full)
i checked under win3.11 api text viewer and this function returnes only tree values and none of them CD_ROM!
while the kernel32 function returnes 5 values,including cd_rom.
Now,about copying kernell to my system:Is there any point to it,if it doesn't return a cd_rom? What to do?
thank you
What a bummer.
If you cant find a kernel API to to the job, try this:
Use Registry API calls to look up the drives in the HKEY_LOCAL_MACHINE key. Have a look in your Registry (using regedit) at HKEY_LOCAL_MACHINE/Enum/ES DI. Youll see CurrentDriveLetterAssignme nt for each drive.
The CurrentDriveLetterAssignme nt for the cdrom is 'CD'.
Im still looking at the feasibilty of this.
If you cant find a kernel API to to the job, try this:
Use Registry API calls to look up the drives in the HKEY_LOCAL_MACHINE key. Have a look in your Registry (using regedit) at HKEY_LOCAL_MACHINE/Enum/ES
The CurrentDriveLetterAssignme
Im still looking at the feasibilty of this.
Wrong registry key.
Its HKEY_LOCAL_MACHINE/Enum/SC SI.
Enumerating the keys below will locate the device with Class value 'CDROM', and the associated CurrentDriveLetterAssignme nt value. There may be more than one CDROM device, and the correct one is found by being the one in the get drive list api.
This is a lot of stuffing around. There has to be something easier.
Its HKEY_LOCAL_MACHINE/Enum/SC
Enumerating the keys below will locate the device with Class value 'CDROM', and the associated CurrentDriveLetterAssignme
This is a lot of stuffing around. There has to be something easier.
theres no such animal as kernel.dll, nor kernel.exe.
It seems the reference is valid, even though the referenced library doesnt exist as a separate entity.
'User' library exists as user.exe. 'shell' library exists as 'shell.dll'. As for 'kernel'? probably something to do with krnl386.exe.
I dont know of the 16-bit API call to the equivalent of the 32-bit calls.
Most focus is on 16-bit to 32-bit conversion. Very little discussion anywhere on 32-bit to 16-bit.
As an alternative to Registry manipulation, creating an OLE automation exe with VB4 or VB5 and calling the 32-bit API function from within the OLE exe and returning it to your app may do it.
It seems the reference is valid, even though the referenced library doesnt exist as a separate entity.
'User' library exists as user.exe. 'shell' library exists as 'shell.dll'. As for 'kernel'? probably something to do with krnl386.exe.
I dont know of the 16-bit API call to the equivalent of the 32-bit calls.
Most focus is on 16-bit to 32-bit conversion. Very little discussion anywhere on 32-bit to 16-bit.
As an alternative to Registry manipulation, creating an OLE automation exe with VB4 or VB5 and calling the 32-bit API function from within the OLE exe and returning it to your app may do it.
I think i have found a simple solution at last.
Declare Function GetDriveType Lib "Kernel" (ByVal nDrive As Integer) As Integer
Function driveType ()
Dim iType As integer
For i = 1 To 26 ' all the drive letters
iType = GetDriveType(i)
if iType = 4 then
MsgBox "Drive " & i & " is a CD-ROM"
endif
Debug.Print iType
Next
end function
I found that the type number retruned for my cd-rom is 4.
The numbers for the other types o fdrive i have are different, so there can be no ambiguity.
Lina, you can transalte the drive number to a letter and return the appropriate functiton value.
Declare Function GetDriveType Lib "Kernel" (ByVal nDrive As Integer) As Integer
Function driveType ()
Dim iType As integer
For i = 1 To 26 ' all the drive letters
iType = GetDriveType(i)
if iType = 4 then
MsgBox "Drive " & i & " is a CD-ROM"
endif
Debug.Print iType
Next
end function
I found that the type number retruned for my cd-rom is 4.
The numbers for the other types o fdrive i have are different, so there can be no ambiguity.
Lina, you can transalte the drive number to a letter and return the appropriate functiton value.
ASKER
Hi!
finally,SOMETHING works!!!
i checked it on my computer and got the followingh results:
for drive A(3.5)----iType=2
for drive B(5.25)---iType=3
for drive C(h.d.)----iType=3
for drive D(h.d.)----iType=3
for drive E(h.d.)----iType=4
for drive F(CD)-----iType=0
those results seem somehow confusing-you got 4 for CD and I got 0?
how to be sure?
finally,SOMETHING works!!!
i checked it on my computer and got the followingh results:
for drive A(3.5)----iType=2
for drive B(5.25)---iType=3
for drive C(h.d.)----iType=3
for drive D(h.d.)----iType=3
for drive E(h.d.)----iType=4
for drive F(CD)-----iType=0
those results seem somehow confusing-you got 4 for CD and I got 0?
how to be sure?
Yes i see what the problem is.
Change the code from:
For i = 1 To 26 ' all the drive letters
to:
For i = 0 To 25 ' all the drive letters
and all will make sense.
The removable media return 2 ( A and B)
The HDDs return 3
CDROM returns 4
Voila.
Change the code from:
For i = 1 To 26 ' all the drive letters
to:
For i = 0 To 25 ' all the drive letters
and all will make sense.
The removable media return 2 ( A and B)
The HDDs return 3
CDROM returns 4
Voila.
ASKER
You're absolutly GREAT!!!
thank you
thank you
ASKER
if so,what do i do? can i copy the kernell file to my system?
is it possible to have both of them?
i checked this function in a pc with win3.11,but it doesn't return
a cr-rom drive yet.it seems there are few versions of older kernel?