` Printed Icetips Article

Icetips Article



Windows API: Using CreateThread to create threads in Clarion
2002-04-04 -- Andrea Rodella
 
Newsgroups: comp.lang.clarion


...hi all, the trick is teh PASCAL attribute on the called procedure
!!!

so the code is as follow :


!* Prototype *
CreateThread(<*GROUP>,ULONG,ULONG,ULONG,ULONG,*ULONG),UNSIGNED,RAW,DLL,PASCAL


!* My procedure*
prcsocket   (long lpgroup),PASCAL

!* declarations *
mygrouptopasstype group,type
field1 cstring(20)
field2 long
  end

mygrouptopass like(mygrouptopasstype)



!* calling Source code *
mygrouptopass.field1=GLO:Client_SocketX
mygrouptopass.field2=1
ThreadHandle = CreateThread( , 0, Address(prcsocket),
Address(mygrouptopass), 0,ThreadID)



!* called procedure *

prcsocket            Procedure(long lpgroup)
localgroup like(mygrouptopass)

  CODE
  message(lpgroup)  !That's ZERO !
 ! and if I try to access the memory with this parameter
  memcpy(address(localgroup), lpgroup,size(mygrouptopasstype))
  message(localgroup.field1)

On Wed, 03 Apr 2002 13:29:34 GMT, geasoft@eudora%$%mail.com (Andrea
Rodella) wrote:

>Hi Andrew,
>you confirm that with this prototyping
>> CreateThread(long lpSecurityAttributes, long Stacksize, long lpFunction, long
lpParameter, |
>>                 long CreationFlags, *long ThreadID),long,raw,pascal
>>    TerminateThread(long hThread, long dwExitCode),bool,pascal,proc
>you are able to pass parameters to the procedure you call with the
>CreateThread?
>
>If yes, please can you send me an extract of your code, to understand
>if it's a problem of my application or of my machine ?? (maybe is
>Win2K that works in a different way ?)
>
>Thanx a lot
>
>Bye
>
>
>
>
>On Tue, 2 Apr 2002 09:51:13 -0500, "Andrew Ireland"
> wrote:
>
>>Hi Andrea,
>>
>>> Please take a look to my code, maybe you see something wrong :
>>>
>>> !* Prototype *
>>> CreateThread(<*GROUP>,ULONG,ULONG,ULONG,ULONG,*ULONG),UNSIGNED,RAW,DLL,PASCAL
>>> It' s maybe  the prototype ?
>>
>>    CreateThread(long lpSecurityAttributes, long Stacksize, long lpFunction, long
lpParameter, |
>>                 long CreationFlags, *long ThreadID),long,raw,pascal
>>    TerminateThread(long hThread, long dwExitCode),bool,pascal,proc
>>
>>This works for me.
>>
>>Regards
>>
>>Andy
>>[Plugware Solutions.com Ltd]
>>[Tel : +44 1249 813335]
>>[Fax : +44 1249 813462]
>>
>>
>>
>
>Andrea Rodella
>http://geasoft.too.it
>geasoft@eudora%$%mail.com
>(antispam - remove %$% from the address)

Andrea Rodella
http://geasoft.too.it
geasoft@eudora%$%mail.com
(antispam - remove %$% from the address)



Printed May 12, 2024, 6:37 am
This article has been viewed/printed 35117 times.
Google search has resulted in 133 hits on this article since January 25, 2004.