64 位模式下的 StrPtr 类型不匹配

StrPtr type mismatch in 64 bit mode

我在 Access 2013 中使用了以下代码(从网站获取)。它没有任何问题。

Private Declare Function GdipCreateBitmapFromFile Lib "gdiplus.dll" (ByVal FileName As Long, bitmap As Long) As Long

If GdipCreateBitmapFromFile(StrPtr(sFileName), hPic) = 0 Then ....

在我为 Access 2013 64 位 运行 时间安装删除 32 位组件后,出现编译器错误。我在 Declare 之后添加 PtrSafe,编译器就可以了。

Private Declare PtrSafe Function GdipCreateBitmapFromFile Lib "gdiplus.dll" (ByVal FileName As Long, bitmap As Long) As Long

If GdipCreateBitmapFromFile(StrPtr(sFileName), hPic) = 0 Then ....

但是,它会出现 运行 时间错误 - StrPtr 中的类型不匹配。不知道怎么解决。

对 64 位使用 LongPtr 而不是 Long。

Private Declare PtrSafe Function GdipCreateBitmapFromFile Lib "gdiplus.dll" (ByVal FileName As LongPtr, bitmap As Long) As Long