用 windows API函数要加什么头文件吗?

2025-05-21 10:44:32
推荐回答(4个)
回答(1):

"windows.h" 呗!
给你个实例——“hello world”

#include

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
PSTR szCmdLine, int iCmdShow)
{
MessageBox (NULL, TEXT ("Hello, Windows 98!"), TEXT ("HelloMsg"), 0) ;

return 0 ;
}

回答(2):

一段简单的示例代码.
先声明API函数GetClassName,FindWindow;
然后在程序中调用就可以了。
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpclassname As String, ByVal nMaxCount As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpclassname As String, ByVal lpWindowName As String) As Long
Private Sub Command1_Click()
Dim lpclassname As String
Dim chwnd As Long
Dim rh As Long
Dim lhwnd As Long
Shell "calc.exe"
chwnd = FindWindow(vbNullString, "计算器")
lpclassname = Space(255)
GetClassName chwnd, lpclassname, 255
End Sub

回答(3):

声明就可以了

回答(4):

只要写出来是WINdows支持的API就行了