![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Mar 2006
Posts: 60
Rep Power: 3
![]() |
Error calling createthread
I'm getting an error when making the following (windows api) call:
createthread(nil,0,@read_winboard,nil, 0,Threadid); The error message says "variable required". read_winboard is an existing procedure, and Threadid is a declared dword. I'm using a slightly modified version of this code. "Variable required" sounds like I need to send a variable instead of a value, in which case it's one of the nils or the zero that need to be changed. I've tried changing things back and forth but with no result, and I can't find any comprehensible info to set things straight. And I don't put too much faith into what and error message "sounds like". So, anyone got any solid info? |
|
|
|
|
|
#2 |
|
Newbie
Join Date: Sep 2007
Posts: 5
Rep Power: 0
![]() |
I am not sure precisely what you mean by is a "declared dword". ThreadID is used by the kernel32.lib function to return the id for the thread that has just been created.
I tried the following code just to be certain it works type ENoThread = class(Exception);
function StartFunc(InVal:DWORD):DWORD;stdcall;
begin
end;
procedure MakeThread;
var AId:DWORD;
AHandle:HWND;
begin
AHandle:=CreateThread(nil,0,@StartFunc,nil,0,AId);
if (AHandle = 0) then raise ENoThread.Create('Could not create thread');
end;and it works just fine. There is one thing you should be aware of - the way Win32 functions are defined in the Windows API help is not always the way they are declared in Delphi. Typically you should look for the external function declaration in the appropriate Delphi unit. If you are not sure begin with Windows.PAS. It is not at all uncommon for parameters that appear as lpSomething in the Windows help file to turn up as Delphi var parameters in the declaration. Hope this helps.
__________________
http://www.explainth.at |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Mar 2006
Posts: 60
Rep Power: 3
![]() |
Re: Error calling createthread
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|