Einzelnen Beitrag anzeigen

Horst0815

Registriert seit: 23. Mai 2011
Ort: Görlitz
150 Beiträge
 
Delphi XE Starter
 
#8

AW: DLL Funktionen einer Klasse exportieren

  Alt 18. Apr 2012, 18:49
Ist ne C Project wo ich mir was Borgen will was mich zumnächsten Problem Führt

Code:
LRESULT WINAPI GetMsgProc(int code, WPARAM wParam, LPARAM lParam)
{
//   AfxMessageBox("12345");
      if(g_hHook == NULL)
      {   // Read the data from the shared resources
         DWORD dwData = 0, dwSize = sizeof(DWORD);
         g_obIPC.Lock();
         g_obIPC.OpenIPCMMF();
         g_obIPC.ReadIPCMMF((LPBYTE)&dwData, dwSize);
         g_obIPC.Unlock();
         g_hHook = (HHOOK)dwData;
      }


   if(code>=0)
   {
      //if(wParam==WM_SCANPWD)
      {
           CString strTemp;
         strTemp="catch the Windows Message\n";

            
         MSG *msg=(MSG *)lParam;
         HWND hWnd, hWndPwdDlg;
         hWnd=(HWND)msg->wParam ;
         hWndPwdDlg=(HWND)msg->lParam;

         //MessageBox(hWndPwdDlg,strTemp,"tip",MB_OK);
         char szBuffer[100];
         SendMessage(hWnd,WM_GETTEXT,sizeof(szBuffer),(LPARAM)szBuffer);
         //MessageBox(hWndPwdDlg,"asdf","dafasdf",MB_OK);
           COPYDATASTRUCT cds;
         cds.cbData=sizeof(cds);
         cds.dwData=(DWORD)hWnd;
         cds.lpData =szBuffer;
         SendMessage(hWndPwdDlg, WM_COPYDATA, (WPARAM)hWnd, (LPARAM)&cds);
         //MessageBox(hWndPwdDlg,"asdf","dafasdf",MB_OK);
         //TRACE("aljflajfl;ajkfla\n");
      
      }
         
   }
   return CallNextHookEx(g_hHook,code,wParam,lParam);
}
übersetzt zu

Delphi-Quellcode:
function GetMsgProc(code: integer; ewParam: WPARAM; elParam: LPARAM): LResult;
// hook code//removal flag//address of structure with message
var
  dwData, dwSize: DWord;
  strTemp: String;
  chWnd, hWndPwdDlg: HWND;
  msg: Windows.TMsg;
  szBuffer: Array [0 .. 99] of AnsiChar;
  cds: COPYDATASTRUCT;
Begin
  // AfxMessageBox("12345");
  if g_hHook = 0 then
  begin // Read the data from the shared resources
    dwData := 0;
    dwSize := sizeof(DWord);
    LockIPCMMF;
    OpenIPCMMF;
    ReadIPCMMF(@dwData, dwSize);
    UnLockIPCMMF;
    g_hHook := dwData;
  end;
  if code >= 0 then
  begin
    if ewParam = WM_SCANPWD then
    begin
      strTemp := 'catch the Windows Message';
      msg.message := elParam;
      chWnd := Windows.PMsg(ewParam)^.message;
      hWndPwdDlg := Windows.PMsg(elParam)^.message;
      MessageBox(hWndPwdDlg, PWideChar(strTemp), 'tip', MB_OK);
      SendMessage(chWnd, WM_GETTEXT, sizeof(szBuffer), LPARAM(@szBuffer));
      // MessageBox(hWndPwdDlg,'asdf','dafasdf',MB_OK);
      cds.cbData := sizeof(cds);
      cds.dwData := chWnd;
      cds.lpData := @szBuffer;
      SendMessage(hWndPwdDlg, WM_COPYDATA, WPARAM(chWnd), LPARAM(@cds));
      // MessageBox(hWndPwdDlg,'asdf','dafasdf',MB_OK);
    end;
  end;
  Result := CallNextHookEx(g_hHook, code, ewParam, elParam);
end;
wird aufgerufen mit

Code:
g_hHook=SetWindowsHookEx(WH_GETMESSAGE,GetMsgProc,g_hInstance,dwThreadId);
was ich zu
g_hHook :=SetWindowsHookEx(WH_GETMESSAGE,GetMsgProc,g_hInstance,dwThreadId); übersetzt hab

wobei er natürlich bei GetMsgProc meckert
  Mit Zitat antworten Zitat