I apologize, i promise i have tried to make it work, but it siply wont work.
I have this code in PowerBASIC:
FUNCTION ThreadFunc(BYVAL x AS LONG) AS LONG
SLEEP 3000
END FUNCTION
FUNCTION PBMAIN () AS LONG
LOCAL hThread AS DWORD
LOCAL ThreadValue AS LONG
LOCAL idthread AS LONG
LOCAL retval AS LONG
ThreadValue = 17
hThread = CreateThread(BYVAL %Null, 0, CODEPTR(ThreadFunc), ThreadValue, _
%THREAD_TERMINATE OR %THREAD_QUERY_INFORMATION, _
BYVAL VARPTR(idThread))
IF hThread <> %INVALID_HANDLE_VALUE THEN
GetExitCodeThread(hThread, Retval)
MSGBOX IIF$(retval=259, "YES, IT WORKS", "NO, IT DOESNT WORK!")
CloseHandle hThread
END IF
END FUNCTION
I have coded it several ways and it always displays "NO, IT DOESNT WORK!"
Apparently the thread is not created with %THREAD_QUERY_INFORMATION, but i dont want to mess with custom security descriptors in Oxygen yet.
Added:
The above code works on PowerBASIC, but on Oxygen GetExitCodeThread() always returns false, and sets the last error to 6: "Invalid handle", or returns false with no errors. According to the docs, it is because it doesnt have the THREAD_QUERY_INFORMATION, but this method does not work and i am not fluent enough on Oxygen to create a security descriptor manually, and even if i do, i do not know if i am doing it correctly. I am also guessing it could be because CreateThread() is inherithing the security descriptor from the executable, but oxygen's executables are created without this security descriptor... maybe?
Can i get some help converting it? Im trying to get the thread status to see if it has finished or not.