Hi,
sorry, ich Esel hab netürlich vergessen Den COde zu posten. Hier ist er:
Code:
#define MAKE_DLL
// INCLUDES //////////////////////////////////////////////////////////////
#include <windows.h>
#include <stdio.h>
#include <fstream>
#include <String.h>
#include "Hook.h"
using namespace std;
#pragma data_seg ("shared")
//iNumInstances = 0;
//HHOOK hMouseHook =0;
#pragma data_seg ()
#pragma comment(linker,"/SECTION:shared,RWS")
// PROTOTYPES ////////////////////////////////////////////////////////////
LRESULT CALLBACK MouseHookProc(int, WPARAM, LPARAM);
// VARIABLES /////////////////////////////////////////////////////////////
HINSTANCE hDllInstance;
HHOOK hMouseHook =0;
int x, y=0;
char message[10];
// METHODS ///////////////////////////////////////////////////////////////
// FUNCTIONS /////////////////////////////////////////////////////////////
int APIENTRY DllMain(HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved)
{
hDllInstance = hInstance;
return TRUE;
}
BOOL CALLBACK InstallHooks(void)
{
if (hMouseHook ==0)
{
hMouseHook = SetWindowsHookEx(WH_MOUSE, MouseHookProc, hDllInstance, NULL);
if(hMouseHook!=NULL)//succesfully installed
{
OutputDebugString("Install");
return TRUE;
}else
{
OutputDebugString("Fehler bei Install");// not installed
return FALSE;
}
}
return FALSE;
}
BOOL CALLBACK UnInstallHooks(void)
{
if (UnhookWindowsHookEx(hMouseHook))//succesfully deinstalled
{
hMouseHook=NULL;
OutputDebugString("De_Install");
return TRUE;
}else
{
OutputDebugString("Fehler bei De_Install");// not deinstalled
return FALSE;
}
}
LRESULT CALLBACK MouseHookProc(int nCode, WPARAM wParam,LPARAM lParam)
{
if(nCode < 0) return CallNextHookEx(hMouseHook, nCode, wParam, lParam); //if not allowed to work ->CallNextHook
//else:start filtering...
if (wParam==WM_RBUTTONDOWN)
{
//MOUSEHOOKSTRUCT* pMouseStruct = (MOUSEHOOKSTRUCT*)lParam;
//if (pMouseStructex);
//x=pMouseStruct->pt.x;
//x=GET_X_LPARAM(lParam);
//mouse_event(MOUSEEVENTF_MOVE,50,50,0,0);
sprintf(message,"%d",x); //convert integer to string
OutputDebugString("JAU");
}
return CallNextHookEx(hMouseHook, nCode, wParam, lParam);
}
Ich habe mir erlaubt, C++ COde zu posten, ich hoffe das ich dafür nicht gesteinigt werde.
Vielleicht kann man mein Problem nun besser verstehen...
Ich habe nämlich genau das NICHT !!! gemacht, was Du gerade erklärt hast.
Nämlich den Hook-
Handle global machen (z.B. hier mit shared segments), sondern habe ihn lokal gehalten, so dass er ja nun
nur dem lokalen Daten-Teil der
DLL existieren sollte. Damit ist er unsichtbar für die anderen Prozesse.
WIESO geht das ganze dann aber trotzdem????
Danke fürs nachdenken....
[edit=sakura] [delphi]->[c] Tags := Mfg, sakura[/edit]