I'm trying to get a program to create a thread on win98. I'm compiling it on winxp x64
My issue with the following code:
it's simply not creating the thread, it fails on the CreateThread(). Not exactly sure what I'm doing wrong on this. I'm probably missing a step, but they don't support win98 on msdn anymore.
Sadly, it works correctly on winxp x64
Any hints as to where I'm going wrong, would be grateful.
It would be a lot easier to not have to compile on the target computer, if at all possible.
I'm using Code::Blocks and gcc.
//Timer.cpp
My issue with the following code:
it's simply not creating the thread, it fails on the CreateThread(). Not exactly sure what I'm doing wrong on this. I'm probably missing a step, but they don't support win98 on msdn anymore.
Sadly, it works correctly on winxp x64
Any hints as to where I'm going wrong, would be grateful.
It would be a lot easier to not have to compile on the target computer, if at all possible.
I'm using Code::Blocks and gcc.
//Timer.cpp
Rich (BB code):
#include "Timer.hpp"
#include <time.h>
#include <windows.h>
#include <iostream>
tm *TargetTime = NULL;
HANDLE ThreadHandle = 0;
DWORD *ThreadID = NULL;
SECURITY_ATTRIBUTES SecurityAttributes;
DWORD WINAPI __Thread_TimeCheck( LPVOID lpParam );
void TimeStartup()
{
std::cout << "Message: Timer loading...";
time_t rawtime;
time ( &rawtime );
TargetTime = localtime ( &rawtime );
SECURITY_DESCRIPTOR SD;
if(InitializeSecurityDescriptor(&SD, SECURITY_DESCRIPTOR_REVISION))std::cout << "...";//std::cout << "inti\n";
else{std::cout << "InitializeSecurityDescriptor fail\n";return ;}
if(SetSecurityDescriptorDacl(&SD, TRUE,(PACL)NULL, FALSE))std::cout << "...";//std::cout << "SetSecurity\n";
else{std::cout << "SetSecurityDescriptorDacl fail\n";return ;}
SecurityAttributes.lpSecurityDescriptor = &SD;
ThreadHandle = CreateThread(&SecurityAttributes, 0, __Thread_TimeCheck, ThreadID, /*CREATE_SUSPENDED*/ 0, ThreadID);
if(ThreadHandle != 0 ) std::cout << "...";
else
{
std::cout << "ThreadCreation Fail\n"; return ;
}
ResumeThread(ThreadHandle);
std::cout << "Loaded\n";
return ;
}
void SetTargetTime(int HH,int MM,int SS)
{
TargetTime->tm_hour = HH;
TargetTime->tm_min = MM;
TargetTime->tm_sec = SS;
return ;
}
bool IsTimeAt()
{
time_t rawtime;
tm * timeinfo;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
if(TargetTime->tm_hour != timeinfo->tm_hour)return false;
if(TargetTime->tm_min != timeinfo->tm_min)return false;
if(TargetTime->tm_sec != timeinfo->tm_sec)return false;
Sleep(100);
return true;
}
void TimeEnd()
{
CloseHandle(ThreadHandle);
return ;
}
tm* GetTime()
{
return TargetTime;
}
DWORD WINAPI __Thread_TimeCheck( LPVOID lpParam )
{
std::cout << "\nMessage: Thread created.\nCommand:";
while(true)
{
if(IsTimeAt() == true)SendMoMessage("ATZ");
Sleep(15);
}
return 0;
}