main.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #define _CRT_SECURE_NO_WARNINGS
  2. #include <windows.h>
  3. #include <stdio.h>
  4. #define PATH L"DLLWin.dll"
  5. #include "../structs.h"
  6. typedef ResultUserAndCount(_cdecl* MyFunction)(FILE*);
  7. int main() {
  8. HINSTANCE hMyDll;
  9. if ((hMyDll = LoadLibrary(PATH)) == NULL) return 1;
  10. MyFunction myFun = (MyFunction)GetProcAddress(hMyDll, "GetFirstAndCounter");
  11. FILE* FileHandle = fopen("ds.csv", "r");
  12. /*wchar_t* buffer = (wchar_t*)malloc(sizeof(wchar_t) * 100);
  13. DWORD count_buff = 100;
  14. DWORD count_char = 0;
  15. while (fscanf(FileHandle, "%s", buffer) == 1) {
  16. MessageBox(NULL, buffer, L"Îøèáêà", MB_ICONERROR);
  17. printf("%s", buffer);
  18. }*/
  19. /* CreateFileW(
  20. L"ds.csv",
  21. GENERIC_READ,
  22. FILE_SHARE_READ,
  23. NULL,
  24. OPEN_EXISTING,
  25. FILE_ATTRIBUTE_NORMAL,
  26. 0
  27. );*/
  28. if (FileHandle == INVALID_HANDLE_VALUE) {
  29. int error = GetLastError();
  30. }
  31. ResultUserAndCount result = myFun(FileHandle);
  32. char* buf = (char*)malloc(sizeof(char) * 100);
  33. snprintf(buf, sizeof buf, "%d", result.count_users);
  34. printf("%s", buf);
  35. FreeLibrary(hMyDll);
  36. return 0;
  37. }