Link to home
Start Free TrialLog in
Avatar of spaznuski
spaznuski

asked on

Declare a Function for NT only

OK I have two functions that use NetApi32.dll but the code i have will only work on NT, How can i write it so that if the exe is running on a 9x machine the functions wont get called.
The Functions are

function NetShareEnum(servername: PWideChar; level: DWORD; bufptr: PBYTE;
  prefmaxlen: DWORD;  entriesread: PDWORD;  totalentries: PDWORD;
  resume_handle: PDWORD): DWORD;   stdcall;  external 'netapi32.dll' Name 'NetShareEnum';

function NetApiBufferFree(Buffer: Pointer): DWORD;
stdcall; external 'netapi32.dll' Name 'NetApiBufferFree';
ASKER CERTIFIED SOLUTION
Avatar of geobul
geobul

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of geobul
geobul

If you want IsNT function to return true for 2000/XP then:
...
  if osv.dwMajorVersion >= 4 then result := true;
...

Regards, Geo
MajorVersion 4 is also used for Win95/98/ME and NT4.
The line should be :
if (OsInfoEx.dwPlatformId = VER_PLATFORM_WIN32_NT) and (Osv.dwMajorVersion = 4) then
  result:=true;

For Win2000 and XP you should use VerifyVersionInfo
.
Peter
Avatar of spaznuski

ASKER

OK, Thanx for the help; I  actually have code like that already and am using it in such a manner for other problems, but after a long break from the code and looking at what is being said, i figured out what i needed to do.
Thanx
spaznuski:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.