by Dermot Balson - Independent Developer
If you use API calls and write in Excel VBA or a form of VB, this should interest you. It is written in an Excel perspective but also applies to 32-bit VB4.
Excel 7 only supports 32-bit API calls, so all those 16-bit calls have to be converted. Where you have to support Excel 5 and Excel 7, you need to provide both sets of calls (sigh). Fortunately, if you can get hold of a text file containing all the 32-bit calls, you can work out the 32-bit equivalents of your current calls. If you need to use 16-bit calls as well (for Excel 5 users), declare both sets, using the Alias parameter in the declaration, to give the 32-bit calls slightly different names. You can then set a variable to store the version someone is using, ie.
Is32Bit = InStr(1, Application. OperatingSystem,"32-bit")<>0 ' Produces True or False OR ExcelVer = Val(Left (Application. Version, 1)) ' Produces 5 or 7
and apply the API calls like so:
If ExcelVer = 7 Then ' 32-bit call Else ' 16-bit call End If
Unfortunately, this isn't the end of it. Win95 doesn't do everything the same way as Win3.X. If you use Excel (or VB) to launch another application and wait for the results, as shown here:
TaskId = Shell("MyProgramName",1) Do While GetModuleUsage(TaskId) >0 ' Waits for shelled application to finish DoEvents Loop
Win95 has no equivalent to GetModuleUsage, because it runs each application in a separate memory space, so it doesn't need task numbers. I resorted to searching window titles with API calls, which works, but is a bit messy.
Then Chris Kinsman (a US developer) gave me this code, which uses a similar principle toGetModuleUsage.
Written by: Dermot Balson