Dll in GUI

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • Hallo Community,

    nachdem mein Problem mit der GUI gelößt wurde, habe ich nun eine einwandfrei funktionierende hübsche Oberfläche: :)

    C-Quellcode

    1. #include <windows.h>
    2. #include <stdio.h>
    3. #include <cstdio>
    4. #ifdef _UNICODE
    5. #if defined _M_IX86
    6. #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
    7. #elif defined _M_X64
    8. #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
    9. #else
    10. #pragma comment(linker,"/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
    11. #endif
    12. #endif
    13. HWND hwndButton;
    14. HWND hwndEdit;
    15. LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
    16. int WINAPI WinMain(HINSTANCE hI, HINSTANCE hPrI, PSTR szCmdLine, int iCmdShow)
    17. {
    18. LPWSTR szName = L"Fensterklasse";
    19. WNDCLASS wc;
    20. wc.style = CS_HREDRAW | CS_VREDRAW;
    21. wc.lpfnWndProc = WndProc;
    22. wc.cbClsExtra = 0;
    23. wc.cbWndExtra = 0;
    24. wc.hInstance = hI;
    25. wc.hIcon = LoadIcon (NULL,IDI_WINLOGO);
    26. wc.hCursor = LoadCursor (NULL, IDC_ARROW);
    27. wc.hbrBackground = (HBRUSH) GetStockObject(LTGRAY_BRUSH);
    28. //wc.hbrBackground = CreateSolidBrush(RGB(0,0,0));
    29. wc.lpszMenuName = NULL;
    30. wc.lpszClassName = szName;
    31. RegisterClass(&wc);
    32. HWND hwnd = CreateWindow(szName, L"<Graphical User Interface>", WS_SYSMENU | WS_SIZEBOX,
    33. 0,0,300,200,NULL,NULL,hI,NULL);
    34. ShowWindow(hwnd, iCmdShow);
    35. UpdateWindow(hwnd);
    36. MSG msg;
    37. while(GetMessage(&msg,NULL,0,0))
    38. {
    39. TranslateMessage(&msg);
    40. DispatchMessage(&msg);
    41. }
    42. return msg.wParam;
    43. }
    44. LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
    45. {
    46. HDC hdc;
    47. PAINTSTRUCT ps;
    48. switch(message)
    49. {
    50. case WM_PAINT:
    51. hdc = BeginPaint(hwnd, &ps);
    52. SetBkMode(hdc,TRANSPARENT);
    53. SetTextColor(hdc,RGB(0,0,0));
    54. TextOut(hdc, 20, 20, L"Wert", 4);
    55. EndPaint(hwnd, &ps);
    56. return 0;
    57. case WM_CREATE:
    58. hwndButton = CreateWindow(L"button", L"Einlesen!", WS_VISIBLE | WS_CHILD | BS_PUSHBUTTON,
    59. 160, 20, 100, 18, hwnd, (HMENU)1, GetModuleHandle(0),0);
    60. hwndEdit = CreateWindow(L"edit",L"50", WS_VISIBLE | WS_CHILD,
    61. 60,20,80,17,hwnd,0, GetModuleHandle(0),0);
    62. break;
    63. case WM_COMMAND:
    64. switch(wParam)
    65. {
    66. case 1:
    67. {
    68. wchar_t text[256];
    69. SendMessage(hwndEdit, WM_GETTEXT, 256, (LPARAM)text);
    70. MessageBox(hwnd, text, L"Edit -- Feld", MB_OK);
    71. break;
    72. }
    73. }
    74. break;
    75. case WM_DESTROY:
    76. PostQuitMessage(0);
    77. return 0;
    78. }
    79. return DefWindowProc(hwnd, message, wParam, lParam);
    80. }
    Alles anzeigen


    In dem rot gekennzeichneten Bereich, lese ich einen Wert aus einem Edit Feld aus und speichere diesen in der Variable "text".

    Nun habe ich eine weitere Datei: Eine Dll.

    C-Quellcode

    1. #include <iostream>
    2. #include <windows.h>
    3. #include <detours.h>
    4. BOOL WINAPI DllMain(HINSTANCE hinstDll, DWORD Reason, LPVOID Reserved)
    5. {
    6. switch(Reason)
    7. {
    8. case DLL_PROCESS_ATTACH:
    9. MessageBox(0,L"Attached.",L"Info",0);
    10. break;
    11. case DLL_PROCESS_DETACH:
    12. MessageBox(0,L"Detached.",L"Info",0);
    13. break;
    14. }
    15. return TRUE;
    16. }
    Alles anzeigen