Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting NT Build Number?
Message
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Title:
Getting NT Build Number?
Miscellaneous
Thread ID:
00410523
Message ID:
00410523
Views:
70
Hi, I can successfully get the build number of any VFP application on Windows 95 and 98. The same code produces a blank when run on a Windows NT (and presumably 2000). Can someone help?
FUNCTION GetBuildNumber
LPARAMETER cExeFile
LOCAL cVersionInfoStructure, nBytes, nBuildInfoStartPos, nBuildInfoLength, cResult

*	these are the API functions with parameters from WIN32API.HLP

DECLARE LONG GetFileVersionInfoSize IN VERSION STRING, LONG
*    LPTSTR  lptstrFilename,	// pointer to filename string
*    LPDWORD  lpdwHandle 	// pointer to variable to receive zero

DECLARE GetFileVersionInfo IN VERSION STRING, LONG, LONG, STRING
*	LPTSTR  lptstrFilename,	// pointer to filename string
*	DWORD  dwHandle,	// ignored 
*	DWORD  dwLen,	// size of buffer
*	LPVOID  lpData 	// pointer to buffer to receive file-version info.

* find out the length of the version info structure
nBytes = GetFileVersionInfoSize(@cExeFile, 0)

IF EMPTY(nBytes)
	cResult = ''
ELSE
	* retrieve the version info structure
	cVersionInfoStructure = SPACE(nBytes)
	= GetFileVersionInfo(@cExeFile, 0, @nBytes, @cVersionInfoStructure)

	* extract the substring with the build number
	nBuildInfoStartPos = ATCC('FileVersion', cVersionInfoStructure) + LEN('FileVersion') +  1
	* build info terminated by CHR(0)
	nBuildInfoLength = AT(CHR(0), SUBSTR(cVersionInfoStructure, nBuildInfoStartPos)) - 1
	cResult = SUBSTR(cVersionInfoStructure, nBuildInfoStartPos, nBuildInfoLength)
ENDIF

CLEAR DLLS
RETURN cResult
ENDFUNC
Petras Virzintas
Next
Reply
Map
View

Click here to load this message in the networking platform