stan下载免费:我用VB做了个放大镜,但测试时提示:实时错误'453': 找不到DLL入口点GetDc in user32,请问是怎么回事?

来源:百度文库 编辑:高考问答 时间:2024/04/30 20:38:27
源代码:
Option Explicit
Private Type POINTAPI
x As Long
y As Long
End Type
Const srccopy = &HCC0020
Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function GetDc Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function stretchblt Lib "gdi32" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal nwidth As Long, ByVal nheight As Long, ByVal hsrcdc As Long, ByVal xsrc As Long, ByVal ysrc As Long, ByVal nsrcwidth As Long, ByVal nsrcheight As Long, ByVal dwrop As Long) As Long
Dim pos As POINTAPI
Private Sub form_load()
Dim usew As Double
Dim useh As Double
usew = Form1.Width / Screen.TwipsPerPixelX
useh = Form1.Height / Screen.TwipsPerPixelX
End Sub
Private Sub start()
Dim sx As Integer
Dim sy As Integer
GetCursorPos pos
sx = IIf(pos.x < 50 Or pos.x > 925, IIf(pos.x < 50, 0, 925), pos.x - 50)
sy = IIf(pos.y < 50 Or pos.y > 680, IIf(pos.y < 50, 0, 680), pos.y - 50)
Caption = "坐标" & sx & "," & sy & "放大镜"
stretchblt hdc, 0, 0, 200, 200, GetDc(0), sx, sy, 100, 100, srccopy
End Sub
Private Sub timer1_timer()
start
End Sub
Private Sub form_dblclick()
Unload Me
End Sub
提示:“stretchblt hdc, 0, 0, 200, 200, GetDc(0), sx, sy, 100, 100, srccopy”这句是黄色的。具体该怎么解决?

找不到入口点有以下几种情况:
1、没有注意大小写。
在Win32中,DLL的函数和VB的函数中必须大小写相同。
2、没有声明入口函数。
你需要在DLL的*.def文件中 加上入口函数,如:
EXPORTS

SetData @1
GetData @2
这样VB程序就可以访问SetData和GetData函数了。其中@1、@2是这两个函数的引用序号,通常在VB中不使用。(参考QA003500 "做一个DLL时,不用def文件不行吗"。)
3、采用C++编译方式。
在C++中编译函数时会将函数名进行转换,如将DLL中的kk(double k)转换为_kk@8。解决的办法有两种:
(1)如果没有使用C++的类,可以将.cpp文件改名为.c,就不进行这种转换了。
(2)在函数定义前加上extern "c" ,如:
extern "c" void _stdcall kk(double k)