Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Delphi (http://www.programmingforums.org/forum41.html)
-   -   Error calling createthread (http://www.programmingforums.org/showthread.php?t=13560)

Xyhm Jul 15th, 2007 12:05 AM

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?

ExplainThat Sep 6th, 2007 12:18 PM

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.

Xyhm Oct 31st, 2007 9:06 AM

Re: Error calling createthread
 
Quote:

Originally Posted by ExplainThat (Post 133443)
Hope this helps.

It might, thx. (Just saw your post, haven't been here for a while).


All times are GMT -5. The time now is 5:58 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC