Re: Editable tables and general planning help

From: Date: Mon, 11 Jul 2005 09:52:36 +0000
Subject: Re: Editable tables and general planning help
References: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16  Groups: php.gtk.general 
Request: Send a blank email to php-gtk-general+get-5949@lists.php.net to get a copy of this message
Hi all, A little more question for Tom, Do your php_win32api crash when registering the api example's CreateThread function? I've got a php_win32api crash when registering the CreateThread, I've tested with 4.3.9 and 4.3.11 php binaries and their extensions, and the same failure... So, It is supposed to work, let's say, to register CreateThread function and start a "dummy" function from a new thread, as you said? Anyway I think it would be useless if can't share memory between processes... it will crash allways even if the api registering process for CreateThread would work? Anyway I'll have to look if CreateProcess does work, it gives you much more control than a simple winexec... :) Thanks for any help, Regards Gonzalo. Gonzalo Monzón escribió:
Hi all! Thank you very much Tom, you made me really happy!!! I'll have a look to its new possibilities when I have some free time, Thank you again! Regards, Gonzalo. Tom Rogers escribió:
Hi, Monday, July 11, 2005, 2:41:27 PM, you wrote: GM> Hi Tom! GM> What you done with the clipboard is very interesting! GM> Could you send me the sources for your php_win32api? GM> I'm trying to do some "strange" things with the api and it could be in GM> help for me. GM> Thanks in advance. GM> Regards, GM> Gonzalo. You can download the source from: http://kwiktemplates.com/w32api.zip just unzip in the php ext directory. The main changes were made to get rid of a crash with a large number of arguments, deal with complex data types and added callbacks. Here is a bit of useless code that demonstrates the added bits by starting a thread in windows to run a function. If the function did anything useful it would crash as php memory can't be shared between processes. <?php dl("php_w32api.dll"); $api =& new win32; if(!$api->defineType("SECURITY_ATTRIBUTES { byte &Length; TEST_TYPE &SecurityDescriptor; bool InheritHandle; }")){ echo "Type SECURITY_ATTRIBUTES failed.\n"; } $api->registerfunction("long CreateThread Alias CreateThread ( SECURITY_ATTRIBUTES &ThreadAttributes, long dwStackSize, cb StartAddress, //new type, name of registered callback long &Parameter, long dwCreationFlags, long &ThreadId ) From kernel32.dll"); $api->registerfunction("long CloseHandle Alias CloseHandle ( long hObject ) From kernel32.dll"); $api->registerfunction(" bool GetExitCodeThread ( long hThread, long &ExitCode ) From kernel32.dll"); // a function to be called by the thread routine function callback($test=false){ static $state = 'Start'; if(!$test){ $state = 'Called'; //called from thread }else{ return $state; //called locally } echo "Callback called by thread.\n"; return 0; } // register the function as a callback $api->registercallback("long callback()"); $ThreadAttributes = $api->InitType('SECURITY_ATTRIBUTES'); $ThreadAttributes->Length = $api->GetTypeSize('SECURITY_ATTRIBUTES'); //set size of struct $dwStackSize = 0; $StartAddress = 'callback'; $Parameter = false; $dwCreationFlags = 0; $ThreadId = 0; //$api->test('callback'); echo "Starting thread \n"; $ret = $api->CreateThread($ThreadAttributes,$dwStackSize,$StartAddress,$Parameter,$dwCreationFlags,$ThreadId); $x=0; while(($x<5)){ $x++; echo callback(1)."\n"; sleep(1); } echo "function returned:$ret pid:$ThreadId\n"; $ExitCode = -1; $ret2 = $api->GetExitCodeThread($ret,$ExitCode); echo "Thread returned $ret2 with exit $ExitCode\n"; $api->CloseHandle($ret); ?>


« previous php.gtk.general (#5949) next »