[fpc-pascal]Win32 API Call

Jim Wilson jawilson at ix.netcom.com
Tue Jun 22 03:20:19 CEST 2004


I'm trying to get a Win32 API call to work, but either I found a bug in FPC 
(not likely) or I'm doing something wrong (more then likely).

There's an API function called GetCurrentHwProfile that doesn't seem to be 
recognized by FPC, so I added it myself using external. However, when I try 
calling the function I don't seem to be getting anything returned. I tried 
checking the Windows GetLastError function, but that doesn't show me 
anything either.

I've included some code that shows what I mean. It's a text mode program, 
compiled under Windows 2000 using FPC version 1.0.6 with the command line 
of: ppc386 -TWin32 -vehnw -WC -XX -Sd

Since I doubt FPC has a bug I'm assuming it's me. Or is it?

********************************************

Program HWprofile;

uses
   windows;

type

   tProfileInfo = packed record
                    Docked : dword;
                    GUID   : ansistring;
                    Name   : ansistring;
                  end;

   pProfileInfo = ^tProfileInfo;

var
   Profile : pProfileInfo;
   Results : boolean;

(*=======================================================================*)
Function GetCurrentHwProfile (var HWProfile: pProfileInfo): boolean; 
external 'advapi32' name 'GetCurrentHwProfileA';
(*=======================================================================*)

BEGIN

   Results := GetCurrentHwProfile (Profile);

   if not (Results) then
   begin
     Profile.GUID := 'Unknown';
     Profile.Name := 'Unknown';
   end;

   writeln ('GUID   : ',Profile.GUID);
   writeln ('Name   : ',Profile.Name);
   writeln ('Results: ',Results,' - ',GetLastError);

END.

Regards,
Jim Wilson





More information about the fpc-pascal mailing list