Newsgroups : Borland : borland.public.delphi.rtl.win32 : 2006 Sep : CryptGetProvParam API - Unicode, ASCII or MBCS?

www.cryer.info
Managed Newsgroup Archive

CryptGetProvParam API - Unicode, ASCII or MBCS?

Subject:CryptGetProvParam API - Unicode, ASCII or MBCS?
Posted by:"Aleksander Oven" (aleksander.ov..@email.si)
Date:Wed, 27 Sep 2006 22:18:12

I have an uneasy feeling when calling CryptGetProvParam API from
advapi32.dll. Here's the prototype:

function CryptGetProvParam(
   hProv: HCRYPTPROV;
   dwParam: DWORD;
   pbData: PBYTE;
   var pdwDataLen: DWORD;
   dwFlags: DWORD
): BOOL; stdcall;

The pbData parameter receives a pointer to a string, depending on the
value of dwParam.

The problem is that MSDN doesn't mention in which format this string
is stored! And since the CryptGetProvParam API only comes in one
flavor (no *A or *W counterparts), I can't really predict the format.

By experimenting on my system I found out that format is definitely not
Unicode. For now, I assume it's ASCII and it works, because the string
that is returned doesn't contain any non-ASCII characters. But I can't
be sure that on some other system with some other return string this
would still be the same.

Then again, maybe it's neither Unicode nor ASCII. It could be a
multi-byte string.

Anyone knows about this?

Regards,
Aleksander Oven


P.S.: I have some C code that I'm using as a reference, and it does
some pretty strange things with this parameter. For starters, it casts
it directly from PByte to PWideChar. When I tried this in Delphi, I
naturally got only garbage. I can show the code if that might help you
help me.

Replies:

www.cryer.info
Managed Newsgroup Archive