Article ID: 129875
Article Last Modified on 7/2/2004
Mode Version 3.0 Version 4.0 -------------------------------------------------- Design/Run Mode 142E 39D2 Run as Executable 01ED 1A90
LIBRARY GetVersionVB
DESCRIPTION 'GetVersion Can be called from Visual Basic'
EXETYPE WINDOWS 3.1
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE SINGLE
HEAPSIZE 4096
EXPORTS
GetVersionVB @1
#include <windows.h>
#include <vbapi.h>
int FAR PASCAL LibMain (HANDLE hInstance, WORD wDataSeg, WORD wHeapSize,
LPSTR lpszCmdLine)
{
if (wHeapSize > 0)
UnlockData (0); //Unlocks the data segment of the library.
return 1;
}
WORD FAR PASCAL _export GetVersionVB( void )
{
unsigned short nVerConst;
nVerConst=VBGetVersion(); //Call VB API
if (nVerConst==VB100_VERSION) //Constant VB100_VERSION in vbapi.h
return 1;
if (nVerConst==VB200_VERSION)
return 2;
if (nVerConst==VB300_VERSION)
{
WORD SS20;
_asm { //Retrieve function table address at SS20
mov ax, SS:[0x0020];
mov SS20, ax;
}
if ( (SS20==0x01ED) || (SS20==0x142E) )
{
return 3;
}
if ( (SS20==0x39D2) || (SS20==0x1A90) )
{
return 4;
}
}
// If we reach this point, none of the addresses were correct
// possibly indicating a new release of VB - so the code returns 0
return 0;
}
int FAR PASCAL _export WEP(int nParam)
{
return 1;
}
Declare Function GetVersionVB Lib "findver.dll" () As Integer
MsgBox Str(GetVersionVB())
Additional query words: 3.00 4.00 vb4win vb4all
Keywords: kbhowto KB129875