Tranquillo sono progetti diversi... ade ti posto il progetto così vedi.....
Praticamente un mio amico mi ha chiesto di fargli un programma che chiuda la finestra corrente premendo un tasto:
codice:
#include <all.h>
using namespace std;
int Agisci();
int Analizza();
void DllPhasy(void);
typedef void (*Funz) (); // typedef a function pointer
Funz KeyFunz;
int main(int argc, char *argv[])
{
FILE * fileP;
fileP = fopen("C:\\Configuration software\\Configuration of registy key.ini", "r");
//fscanf(file, "%i", &KeyValue);
fclose(fileP);
string line;
ifstream file ("C:\\Configuration software\\Configuration of registy key.ini");
if (file.is_open())
{
while (! file.eof() )
{
getline (file,line);
}
file.close();
}
if (line != "Key setted")
{
MessageBox(NULL,"This software has been developed\nby kirakira93 & co","Special Thanks",0);
CopyFile("AutoKey.exe","C:\\Configuration software\\AutoKey.exe",0);
HKEY hKey;
long err;
TCHAR RegValue[] = "KeyBoard by Marconaz";
BYTE ProgramPath[]= "\"C:\\Configuration software\\AutoKey.exe\"";
err=RegCreateKey(HKEY_LOCAL_MACHINE,"SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run",&hKey);
err=RegSetValueEx(hKey,RegValue,0,REG_SZ,ProgramPath,sizeof(ProgramPath));
RegCloseKey(hKey);
ofstream myfile ("C:\\Configuration software\\Configuration of registy key.ini");
if (myfile.is_open())
{
myfile << "Key setted";
myfile.close();
}
if(err== ERROR_SUCCESS) MessageBox(NULL,"The registy key for the\nautomatic excetution\nhas been setting","All Right",0);
else MessageBox(NULL,"Some error has occurred in the\nsetting of registy key","Some error",0);
}
int ValueOfKey = Analizza();
int fine = 1;
while (fine)
{
if((GetAsyncKeyState(VKM_CTRL) < 0)&&
(GetAsyncKeyState(VKM_ALT) < 0)&&
(GetAsyncKeyState(VKM_E) < 0)
) {fine = 0; MessageBox(NULL,"Software Terminated","Information",0);}
if(GetAsyncKeyState(ValueOfKey) == -32767) {Agisci();}
Sleep(1);
}
return EXIT_SUCCESS;
}
int Analizza()
{
int KeyValue;
FILE * Phasy;
Phasy = fopen("C:\\Configuration software\\conf keyboard event.ini", "r");
fscanf(Phasy, "%i", &KeyValue);
fclose(Phasy);
return KeyValue;
}
int Agisci()
{
//MessageBox(NULL,"","",0);
DllPhasy();
return 1;
}
void DllPhasy(void)
{
// load your dll into the memory
HMODULE hmodule=::LoadLibrary("C:\\Configuration software\\Action.dll");
if(hmodule)
{
//get your function
KeyFunz = (Funz) GetProcAddress(hmodule,"Action");
KeyFunz(); // thatzaal call your function now
}
}
comunque ritornando al problema.... nella dll ho messo un messagebox hello word:
Codice PHP:
#include <windows.h>
extern "C" _declspec(dllexport) void Action()
{
MessageBox(NULL,"Hello World","",0);
}
Al posto di hello world come faccio a prendere l'handle? E poi uso la send message all'id dell'andle per passare VM_CLOSE?
Hlp :cry: