?
Solved

Declare a Function for NT only

Posted on 2003-03-15
5
Medium Priority
?
226 Views
Last Modified: 2010-04-04
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';
0
Comment
Question by:spaznuski
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 17

Accepted Solution

by:
geobul earned 50 total points
ID: 8143433
Hi,

Try this:

function IsNT: boolean;
var osv: TOSVERSIONINFO;
begin
  result := false;
  FillChar(osv,SizeOf(osv),0);
  osv.dwOSVersionInfoSize := SizeOf(osv);
  if GetVersionEx(osv) then
    if osv.dwMajorVersion = 4 then result := true;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  if IsNT then ...
  else ...;
end;

Regards, Geo
0
 
LVL 17

Expert Comment

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

Regards, Geo
0
 
LVL 2

Expert Comment

by:PeterLarsen
ID: 8143648
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
0
 

Author Comment

by:spaznuski
ID: 8144943
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
0
 

Expert Comment

by:CleanupPing
ID: 9316767
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.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question