Re: Help - I cant get SfcIsFileProtected or SfcGetNextProtectedFile to work.

From: Rob Kennedy (me3_at_privacy.net)
Date: 04/11/04


Date: Sun, 11 Apr 2004 15:32:46 -0500

mc wrote:
> type
> TPROTECTED_FILE_DATA = packed record
> FileName: array [0..256] of WideChar;

The header you translated this from should have used the MAX_PATH macro
for the character count. You should do the same. (MAX_PATH's current
definition is 260, but that doesn't matter when you get into the habit
of using named constants.)

> FileNumber : DWORD;
> end;
>
> TSfcGetNextProtectedFile = function (Handle: THandle; ProtFileData:
> TPROTECTED_FILE_DATA): Boolean ;

The ProtFileData parameter should be declared as a PProtectedFileData --
a pointer to the structure. As an alternative, you can declare it as a
var or const TProtectedFileData. One way or another, you need to ensure
that a pointer is passed.

The API function is declared as returning a BOOL, which is *not* the
same as Delphi's Boolean. The API type is three bytes wider, and those
three bytes can be very important.

Finally, the API function almost certainly uses the stdcall calling
convention; definitely not Delphi's default register calling convention.

type
   TSfcGetNextProtectedFile = function(RpcHandle: THandle; var
ProtFileData: TProtectedFileData): Bool; stdcall;

-- 
Rob


Relevant Pages

  • Re: Help - I cant get SfcIsFileProtected or SfcGetNextProtectedFile to work.
    ... > a pointer to the structure. ... The API type is three bytes wider, ... the API function almost certainly uses the stdcall calling ... definitely not Delphi's default register calling convention. ...
    (comp.lang.pascal.delphi.misc)
  • RE: Printing a form.
    ... Apprecite if you could convert below code into VB.NET ... Declare the API function. ... Please note the BitBlt function used in Step 2. ...
    (microsoft.public.dotnet.framework.windowsforms)
  • Re: New Shortcut Wizard
    ... Since you must declare the function with _stdcall calling convention.... ... This all leads to: ... LibHandle:= LoadLibrary; ...
    (borland.public.delphi.nativeapi)
  • Re: dll wont work with VB6
    ... The error I get under VB is Runtime error 49, "Bad DLL calling ... convention". ... VB can only call exported functions that use __stdcall calling ... I thought there was a CDecl keyword you could tag on the Declare Function ...
    (microsoft.public.vc.language)
  • Re: HOW TO: Declare DLL functions at run time only
    ... where does declare a delegate function is different from ... declaring an Api function? ... It declares in my opinon different types. ...
    (microsoft.public.dotnet.languages.vb)