Delphi Xe4. For example, there are two functions (Unicode):
CryptAcquireContext, CryptGetProvParam.
I read on MSDN description:
1) http://msdn.microsoft.com/en-us/library/windows/desktop/aa379886(v=vs.85).aspx
BOOL WINAPI CryptAcquireContext(
_Out_ HCRYPTPROV *phProv,
_In_ LPCTSTR pszContainer,
_In_ LPCTSTR pszProvider,
_In_ DWORD dwProvType,
_In_ DWORD dwFlags);
2) http://msdn.microsoft.com/en-us/library/windows/desktop/aa379929(v=vs.85).aspx
BOOL WINAPI CryptEnumProviders(
_In_ DWORD dwIndex,
_In_ DWORD *pdwReserved,
_In_ DWORD dwFlags,
_Out_ DWORD *pdwProvType,
_Out_ LPTSTR pszProvName,
_Inout_ DWORD *pcbProvName);
If I understand correctly, then translated into Delphi it should be like this:
{S} Function CryptAcquireContext(Out hpProv:PNativeUInt;Const Container:PWideChar;
Const Provider:PWideChar;Const ProvType:DWord;Const Flags:DWord):Bool; StdCall; External Advapi32dll Name 'CryptAcquireContextW';
{S} Function CryptEnumProviders(Const Index:DWord;Const Reserved:PDWord;Const Flags:DWord;
Out ProvType:PDWord;Out pszProvName:DWord;Var pcbProvName:DWord):Bool; StdCall; External Advapi32dll Name 'CryptEnumProvidersW';
Are primarily interested in the return parametrametry, marked with "OUT" and "VAR" (Out, InOut). As such, I do not work all kinds of examples that are found in interente. For example calls:
Procedure Test;
var hProv:NativeUInt;provName: array[0..200] of char;dwProvType: DWORD;
begin
...
if not CryptAcquireContext(@hProv, nil, provName, dwProvType,CRYPT_VERIFYCONTEXT) then RaiseLastOSError;
...
while CryptEnumProviders(i, nil, 0,@dwProvType, nil, @cbName)) do
begin
..
end;
Give a compile error: "E2033 Types of actual and formal var parameters must be identical" - refers to the @ hProv and @ dwProvType. If you like to replace OUT on VAR and text @dwProvType on PDword(dwProvType), gives an error: "E2197 Constant object cannot be passed as var parameter".
If I do not specify the input and output parameters (like this - http://www.bvbcode.com/code/oyma7f3h-1618784, string №692), everything compiles, runs and work fine (Const - no effect):
{S} Function CryptAcquireContext(hpProv:PNativeUInt;Container:PWideChar;Provider:PWideChar;ProvType:DWord;Flags:DWord):Bool; StdCall; External Advapi32dll Name 'CryptAcquireContextW';
{S} Function CryptEnumProviders(Index:DWord;Reserved:PDWord;Flags:DWord;ProvType:PDWord;pszProvName:PWideChar;pcbProvName:PDWord):Bool; StdCall; External Advapi32dll Name 'CryptEnumProvidersW';
In the past, the question I was advised to take the values of the functions of the JEDI API. I downloaded the latest version of (http://sourceforge.net/projects/jedi-apilib/), I see (unit JwaWinCrypt):
function CryptAcquireContext(var phProv: HCRYPTPROV; pszContainer: LPCTSTR;
pszProvider: LPCTSTR; dwProvType: DWORD; dwFlags: DWORD): BOOL; stdcall;
function CryptEnumProviders(dwIndex: DWORD; pdwReserved: LPDWORD; dwFlags: DWORD;
var pdwProvType: DWORD; pszProvName: LPTSTR; var pcbProvName: DWORD): BOOL; stdcall;
Instead, call the values of "OUT" and "INOUT" write "VAR". But these my examples are not work fine. And pdwProvType and pcbProvName of type DWORD, although the description is DWORD * = PDWORD?
Questions:
1) How to do it right. MSDN OUT = Delphi OUT or VAR? IN_OUT = Delphi VAR? Or they do not specify?
2) Do I need to write Const? IN = Delphi Const?
3) The types with pointers. DWORD = Delphi Dword. Ok. DWORD* = Delphi PDWROD (or all marked * = Delphi Pointer type)?
p.s. Sorry for the bad English.
Out
is next to not-implemented for Delphi. Aside from Interface-references it is mostly synonim tovar
– Arioch 'The