stdafx.cpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // stdafx.cpp : 只包括标准包含文件的源文件
  2. // QRText.pch 将作为预编译头
  3. // stdafx.obj 将包含预编译类型信息
  4. #include "stdafx.h"
  5. HMODULE g_hQRCodeLibrary = NULL;
  6. API_GetQRCodeImg g_GetQRCodeImg = NULL;
  7. API_ShowQRCodeBitmap g_ShowQRCodeBitmap = NULL;
  8. API_ShowQRCodeOnDC g_ShowQRCodeOnDC = NULL;
  9. BOOL LoadQRCodeLibrary()
  10. {
  11. if ( g_hQRCodeLibrary == NULL )
  12. {
  13. g_hQRCodeLibrary = ( HMODULE )LoadLibrary(_T("QRCode.dll"));
  14. if ( g_hQRCodeLibrary == NULL )
  15. return FALSE;
  16. }
  17. g_GetQRCodeImg = (API_GetQRCodeImg)GetProcAddress(g_hQRCodeLibrary, "GetQRCodeBitmap");
  18. if ( g_GetQRCodeImg == NULL )
  19. {
  20. FreeLibrary(g_hQRCodeLibrary);
  21. return FALSE;
  22. }
  23. g_ShowQRCodeBitmap = (API_ShowQRCodeBitmap)GetProcAddress(g_hQRCodeLibrary, "ShowQRCodeBitmap");
  24. if ( g_ShowQRCodeBitmap == NULL )
  25. {
  26. FreeLibrary(g_hQRCodeLibrary);
  27. return FALSE;
  28. }
  29. g_ShowQRCodeOnDC = (API_ShowQRCodeOnDC)GetProcAddress(g_hQRCodeLibrary, "ShowQRCodeOnDC");
  30. if ( g_ShowQRCodeOnDC == NULL )
  31. {
  32. FreeLibrary(g_hQRCodeLibrary);
  33. return FALSE;
  34. }
  35. return TRUE;
  36. }
  37. void showmsg()
  38. {
  39. AllocConsole(); // 开辟控制台;
  40. SetConsoleTitle(_T("lyfz调试输出")); // 设置控制台窗口标题;
  41. freopen("CONOUT$", "w+t", stdout); // 重定向输出;
  42. freopen("CONIN$", "r+t", stdin); // 重定向输入;
  43. HWND hWnd = NULL;
  44. again:
  45. hWnd = ::FindWindow(NULL, _T("lyfz调试输出"));
  46. if( hWnd )
  47. {
  48. if (!::SetWindowPos(hWnd, HWND_TOPMOST, 0,0,0,0, SWP_NOMOVE | SWP_NOSIZE))
  49. {
  50. printf(_T("前置设置失败\n"));
  51. }
  52. else
  53. {
  54. printf(_T("前置设置成功\n"));
  55. }
  56. }
  57. else
  58. {
  59. goto again;
  60. }
  61. }