[fpc-pascal]When to use pointers with win32

memsom at interalpha.co.uk memsom at interalpha.co.uk
Tue Nov 26 16:40:54 CET 2002

> As far I can see, your explanations are wrong, because the CreateThread
> function is documented in then win32.hlp as to require as the 6th parameter
> an 'address of returned thread identifier'. But the lines
> var pthreadID: ^cardinal;
> ....
> waveInThread := CreateThread(0, 0, @waveInProc, 0, 0, pthreadID);
> gives the compiler error:
> Incompatible type for arg no. 6: Got ^ULONG, expected ULONG
> whereas the lines:
> var threadID: cardinal;
> ....
> waveInThread := CreateThread(0, 0, @waveInProc, 0, 0, threadID);
> compiles with no error.
> This shows that I cannot call the original CreateThread API, but only a
> Pascal style redefined function (which actually passes the pointer to the
> threadID, because the function will set the value for me).
> So I still ask for how to find information about the Pascal definitions in
> the windows unit.

Delphi's definition is:

function CreateThread(lpThreadAttributes: Pointer;
  dwStackSize: DWORD; lpStartAddress: TFNThreadStartRoutine;
  lpParameter: Pointer; dwCreationFlags: DWORD; var lpThreadId: DWORD): 
THandle; stdcall;

DWORD = Cardinal for our purposes (longword is more correct I guess.)

This tells me that for compatibilitys sake, and Pascal readability (i.e. no 
pointers) is the version I would like to have to use (and do.)


This message was sent using Mistral WebMail.

More information about the fpc-pascal mailing list