windows API functions

121 views
Skip to first unread message

Doug Pease

unread,
Jul 10, 2012, 10:12:55 PM7/10/12
to mapi...@googlegroups.com

 

Hi listers

 

I have an a MapBasic application which I have previously compiled in Version 7.5 on Windows Vista and run successfully for quite a while now. I am now trying to compile it again after making some updates in MB version 9.5 on Windows 7. In the application I use a function called ConnectedtoNetwork() which uses the Windows API functions GetDriveType.   On compiling the application it comes up with the error message ‘Unresolved Sub or Function ConnectedtoNetwork.’  Now the function has been Declared and as I said worked fine in the past. I’m now stumped after trying a few things to resolve this issue and cant find any reference to any changes on the net.

 

What I’m wondering is, has the Windows kernel32 file changed between versions. Any ideas on how to resolve this issue!

 

Regards

Doug

 

robert crossley

unread,
Jul 10, 2012, 10:33:25 PM7/10/12
to mapi...@googlegroups.com

Are you using a 64 bit computer now?  Most of the declarations define a DLL such as User32, so suspect they are for 32 bit only.

 

R

--
You received this message because you are subscribed to the
Google Groups "MapInfo-L" group.To post a message to this group, send
email to mapi...@googlegroups.com
To unsubscribe from this group, go to:
http://groups.google.com/group/mapinfo-l/subscribe?hl=en
For more options, information and links to MapInfo resources (searching
archives, feature requests, to visit our Wiki, visit the Welcome page at
http://groups.google.com/group/mapinfo-l?hl=en

Lars I. Nielsen (GisPro)

unread,
Jul 11, 2012, 1:29:32 AM7/11/12
to mapi...@googlegroups.com
MapInfo Pro is still 32 bit, so running it on a 64 bit system just means that it runs in the 32 bit subsystem named Wow64

The 32 bit kernel DLLs will reside here, which will be different than when running on a 32 bit OS (although there may be some internal "redirection" going on to fool 32 bit apps to think the OS is 32 bit).


Best regards / Med venlig hilsen
Lars I. Nielsen
GIS & DB Integrator
GisPro

Mustafa ÖZÇETiN

unread,
Jul 11, 2012, 5:58:16 AM7/11/12
to mapi...@googlegroups.com
Now that you have MapBasic 9.5, rather than using a Windows API, using a .NET DLL to get the drive type may be a workaround, so I have written a C# DLL to get the drive types. There is a single method in this DLL, namely GetDriveType, which takes a string as a drive name and returns the drive type. I think this is what you want to achieve.

Please note that to call the GetDriveType method, you must use a specific format for the drive name parameter. For example, to get the type of the drive C, use

GetDriveType("C:\")

which returns "Fixed" (without the quotes) as the drive type. (Attention to "C:\" format.)

I have tested the DLL on my machine (32-bit XP) and got the following results:

Print GetDriveType("C:\") 'HD Drive
Print GetDriveType("D:\") 'HD Drive
Print GetDriveType("E:\") 'HD Drive
Print GetDriveType("F:\") 'DVD-RAM
Print GetDriveType("H:\") 'Mapped Network Drive
Print GetDriveType("J:\") 'DVD
Print GetDriveType("R:\") 'RAMDISK
   
Output:

Fixed
Fixed
Fixed
CDRom
Network
CDRom
Fixed

I do not have a 64-bit Windows at hand now, so I could not test it with 64-bit but I hope it will work.

You can download all the files including the source:


Please let me know the result.

HTH
 
Mustafa OZCETiN
Senior Researcher

The Scientific and Technological Council of Turkiye
Ankara / Turkiye

Evil "G"

unread,
Jul 11, 2012, 9:55:06 AM7/11/12
to mapi...@googlegroups.com

Dim allDrives() As DriveInfo = DriveInfo.GetDrives()
Dim d As DriveInfo
Dim found As Boolean
Dim file_name_string As String

      
this is a code segment in VB.net
Imports System
Imports System.IO

 
Create your DLL in C# or C++ or VB and call each one of these commands as a function
 
this code place the information in to a drop down menu box
 
Dim allDrives() As DriveInfo = DriveInfo.GetDrives()
Dim d As DriveInfo
 
 

        For Each d In allDrives
            ListBox1.Items.Add("Drive" & d.Name)
            'ListBox1.Items.Add("  File type: " & d.DriveType)
            If d.IsReady = True Then
                ComboBoxDrives.Items.Add(d.Name)
                ListBox1.Items.Add("  Volume label: >" & d.VolumeLabel)
                'ListBox1.Items.Add("  File system: " & d.DriveFormat)
                'ListBox1.Items.Add("  Available space to current user: bytes" & d.AvailableFreeSpace)
                'ListBox1.Items.Add("  Total available space:           bytes" & d.TotalFreeSpace)
                'ListBox1.Items.Add("  Total size of drive:             bytes " & d.TotalSize)

               
        Next

Mustafa ÖZÇETiN

unread,
Jul 12, 2012, 2:47:08 AM7/12/12
to mapi...@googlegroups.com
As a future reference: I have tested the DLL with 64-bit Windows7 at home and it works perfectly.
 
Mustafa



From: Mustafa ÖZÇETiN <mustafao...@yahoo.com>
To: "mapi...@googlegroups.com" <mapi...@googlegroups.com>
Sent: Wednesday, July 11, 2012 12:58 PM
Reply all
Reply to author
Forward
0 new messages