在搞乱多线程,回调,win32 api功能以及其他麻烦的问题时,我收到了一个想法事件.(呵呵呵)
如果,而不是(设计一个类时或静态)回调函数定义一个全球性的,而不是我指派DefWindowProc为lpfnWndProc注册窗口类的时候,然后运行在一个单独的线程整个事件循环?
这样我就不必在类中实现回调this时解决问题,
并且主线程的执行继续进行,让你从那个被遗忘的循环中解放出来,允许你做任何事情,甚至打开另一个窗口(耶!)
"正常"方式:
LRESULT CALLBACK WndProc(...)
{
... // process event information
return DefWindowProc(...);
}
int CALLBACK WinMain(...)
{
... // initialize whatever needs initializing :)
WNDCLASSEX wc;
...
wc.lpfnWndProc = WndProc;
... // register the class, create the window, etc...
MSG msg;
while(GetMessage(&msg, 0, 0, 0) != 0)
{
... // TranslateMessage(&msg) if you want/need it
DispatchMessage(&msg); // dispatches the message to WndProc
}
return static_cast<int>(msg.wParam);
}
Run Code Online (Sandbox Code Playgroud)
我新发现的令人敬畏的方式:
DWORD …Run Code Online (Sandbox Code Playgroud) 因此,我一直在尝试在 python 客户端和 python 服务器之间建立 SSL 连接,其中两者都有单独的证书来相互验证,并且两个证书都由一个 CA(它也恰好是根 CA)签名. 这应该使它们对彼此都有效,对吗?
到目前为止,我的方法是创建一个 bash 脚本来完成这一切:
#!/bin/bash
BOLD=$(tput bold)
CLEAR=$(tput sgr0)
echo -e "${BOLD}Generating RSA AES-256 Private Key for Root Certificate Authority${CLEAR}"
openssl genrsa -aes256 -out Root.CA.example.llc.key 4096
echo -e "${BOLD}Generating Certificate for Root Certificate Authority${CLEAR}"
openssl req -x509 -new -nodes -key Root.CA.example.llc.key -sha256 -days 1825 -out Root.CA.example.llc.pem
echo …Run Code Online (Sandbox Code Playgroud)