DirectDraw 中的 CreateSurface 在 x64 上返回 E_INVALIDARG
在以下代码中,当为 x64 构建时,hRet 设置为 E_INVALIDARG。
相同的代码在 32 位中始终可以正常工作。输入中唯一明显的区别是 ddsd 的大小,由于指针大小的原因,在 64 位模式下它要大 4 个字节。
HRESULT hRet;
DDSURFACEDESC2 ddsd;
LPDIRECTDRAWSURFACE4 pTempDDrawSurface = NULL;
ZeroMemory(&ddsd,sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps |= DDSCAPS_PRIMARYSURFACE;
// Create primary surface
hRet = m_pRootDDrawObj->CreateSurface(&ddsd, &pTempDDrawSurface, NULL);
if (hRet != DD_OK)
return -3; //gets here with E_INVALIDARG, but GetLastError() is 0.
(操作系统为win7)。感谢您的任何建议。
In the following code, hRet gets set to E_INVALIDARG when built for x64.
The same code always works ok in 32 bit. The only clear difference in input is the sizeof ddsd, which is 4 bytes larger in 64 bit mode, because of a pointer size.
HRESULT hRet;
DDSURFACEDESC2 ddsd;
LPDIRECTDRAWSURFACE4 pTempDDrawSurface = NULL;
ZeroMemory(&ddsd,sizeof(ddsd));
ddsd.dwSize = sizeof(ddsd);
ddsd.dwFlags = DDSD_CAPS;
ddsd.ddsCaps.dwCaps |= DDSCAPS_PRIMARYSURFACE;
// Create primary surface
hRet = m_pRootDDrawObj->CreateSurface(&ddsd, &pTempDDrawSurface, NULL);
if (hRet != DD_OK)
return -3; //gets here with E_INVALIDARG, but GetLastError() is 0.
(OS is win7). Thanks for any advice.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
解决方案:
solution:
这是一个老问题,但我在移植一些遗留代码时遇到了同样的问题。这里的第一件事是 CreateSurface() 期望“dwSize”字段为 0x88,而默认情况下 MSVC 将其打包为 0x80 字节。
应用上面 glutz 的
pack
修复确实可以解决该问题,但是CreateSurface()
调用会返回 E_NOINTERFACE (0x80004002)。到目前为止,我只能猜测 x64 根本不支持 DirectDraw 表面。This is an old question, but I just ran into the same problem while porting some legacy code. The first thing here is that
CreateSurface()
expects the `dwSize´ field to be 0x88, while by default MSVC packs it into 0x80 bytes.Applying the
pack
fix by glutz above does correct that issue, however then theCreateSurface()
call returns E_NOINTERFACE (0x80004002). So far I can only guess that DirectDraw surfaces are simply not supported on x64.