我对c ++和oo很新,所以这可能是非常愚蠢的事情.这完全在我的include语句之后的代码中.
enum ObjType { CUBE, CONE, };
typedef struct {
ObjType type;
float x;
float y;
float z;
int selected;
} object;
static object objects[] =
{
{ CUBE, rand()%11-4, rand()%-10-5, rand()%-65-55, 0},
{ CONE, rand()%11-4, rand()%-10-5, rand()%-65-55, 0},
}
Run Code Online (Sandbox Code Playgroud)
我在我的主要方法中调用srand,传入当前时间.但是,每次程序错误时,这都会生成相同的随机数.我不明白的是什么?
我有一个从DLL导出的简单的C ++代码。
DWORD WINAPI MessageBoxThread(LPVOID lpParam)
{
MessageBox(0, L"Test", L"Test", 0);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
这是我的称呼方式
typedef DWORD(*MessageBoxThread)(LPVOID);
int StartMessageBoxThread() {
MessageBoxThread ShowMessageBox;
HMODULE testModule = LoadLibrary(L"C:\\Users\\david\\COMServer.dll");
ShowMessageBox = (MessageBoxThread)GetProcAddress(testModule, "MessageBoxThread");
ShowMessageBox(NULL);
FreeLibrary(testModule);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我在ShowMessageBox()行的KernelBase.dll中引发了异常,该异常在写入内存位置时涉及访问冲突。
我不明白我在做什么错。两个Visual Studio项目都设置为Unicode,并且我知道使用L前缀表示宽字符串。
我可以调试并逐步进入DLL,看到函数的地址,因此调用函数的代码看不到任何错误。