I have a little problem with Qt , here is my code :
SessionSnatcher.h:
#ifndef SESSIONSNATCHER_H
#define SESSIONSNATCHER_H
#include <Windows.h>
#include <QThread>
#include <QtCore>
#include <QDebug>
class SessionSnatcher : public QThread
{
public:
SessionSnatcher();
~SessionSnatcher();
void run();
void SetPID(int pid);
void SetTID(int tid);
int GetPID();
int GetTID();
HWND GetCOProductControl();
private:
//HWND GetCOProductControl();
void CALLBACK SessionSnatcher::handler(HWINEVENTHOOK hook , DWORD event , LONG idChild , LONG idObject , DWORD dwEventThread , DWORD dwmsEventTime);
HWINEVENTHOOK hook;
int PID , TID;
};
#endif // SESSIONSNATCHER_H
SessionSnatcher.cpp :
#include "sessionsnatcher.h"
SessionSnatcher::SessionSnatcher()
{
}
SessionSnatcher::~SessionSnatcher()
{
UnhookWinEvent(hook);
}
void CALLBACK SessionSnatcher::handler(HWINEVENTHOOK hook , DWORD event , LONG idChild , LONG idObject , DWORD dwEventThread , DWORD dwmsEventTime)
{
}
void SessionSnatcher::run()
{
hook = SetWinEventHook(EVENT_SYSTEM_FOREGROUND , EVENT_SYSTEM_FOREGROUND , NULL , &SessionSnatcher::handler , PID , TID , WINEVENT_OUTOFCONTEXT);
}
HWND SessionSnatcher::GetCOProductControl()
{
HWND TPanel = FindWindow(L"TPanel" , NULL);
return TPanel;
}
void SessionSnatcher::SetPID(int pid)
{
PID = pid;
}
void SessionSnatcher::SetTID(int tid)
{
TID = tid;
}
int SessionSnatcher::GetPID()
{
return PID;
}
int SessionSnatcher::GetTID()
{
return TID;
}
And now i keep getting this error :
D:\TT\sessionsnatcher.cpp:25: error: C2664: 'HWINEVENTHOOK SetWinEventHook(DWORD,DWORD,HMODULE,WINEVENTPROC,DWORD,DWORD,DWORD)' : cannot convert argument 4 from 'void (__stdcall SessionSnatcher::* )(HWINEVENTHOOK,DWORD,LONG,LONG,DWORD,DWORD)' to 'WINEVENTPROC'
There is no context in which this conversion is possible
Before this i was using "handler" instead of "&SessionSnatcher::handler" but i had a problem saying it was a member and it cant be used like that. Now i cant work it out. It worked well on Visual Studio When i tried it , all i had to do was cast like (WINEVENTPROC)handler , but i think since im using a separate class i cant do that anymore.
Any tips ?