[fpc-pascal]Win32 API Call

Peter Vreman peter at freepascal.org
Tue Jun 22 07:27:52 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;

ansistring is a fpc/delphi specific type. WinAPI uses pchar

>
>    pProfileInfo = ^tProfileInfo;
>
> var
>    Profile : pProfileInfo;
>    Results : boolean;
>
> (*=======================================================================*)
> Function GetCurrentHwProfile (var HWProfile: pProfileInfo): boolean;
> external 'advapi32' name 'GetCurrentHwProfileA';
>

You are missing stdcall calling directive







More information about the fpc-pascal mailing list