gpt4 book ai didi

winapi - 如何使用 win32 在 D 中创建 Windows?

转载 作者:行者123 更新时间:2023-12-02 03:42:48 25 4
gpt4 key购买 nike

您好,我正在尝试在 D 中使用 win32 打开一个窗口,但遇到了一些问题。当我调用 CreateWindowA 时,程序崩溃了。

这是我的代码:

this.fenetrePrincipale = CreateWindowA(this.classeFenetre.lpszClassName, toStringz(title), WS_OVERLAPPEDWINDOW, 0, 0, 100, 100, null, null, this.hInstance, null);

与:

this.classeFenetre.lpszClassName = toStringz("classeF");
this.hInstance = GetModuleHandleA(null);

string title = "test";

当我启动 exe 时,程序崩溃了,我得到:

Process terminated with status -1073740791

在代码:: block 上。

最佳答案

错误代码-1073740791(或0xc0000409)是由堆栈缓冲区溢出引起的(不是溢出,如耗尽堆栈,而是写入堆栈中不应该写入的位置)。

您显示的调用看起来没问题。但您没有向我们展示类注册代码,更重要的是,您注册的 WndProc 。我不确定你如何在 D 中执行此操作,但你的 WndProc 需要声明 __stdcall,以便它符合 Windows 假定的调用约定。这是导致 CreateWindow 崩溃的常见问题。

关于winapi - 如何使用 win32 在 D 中创建 Windows?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7635609/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com