[求助]VC中怎么调用DLL中的方法
在VB中有一个这样的声明.
Private Declare Function NtQuerySystemInformation Lib "ntdll.dll" ( _
ByVal dwInfoType As Long, _
ByVal lpStructure As Long, _
ByVal dwSize As Long, _
dwReserved As Long) As Long
用VC来应该怎么写?
急啊.
问题点数:100、回复次数:4Top
1 楼syy64(太平洋)回复于 2006-06-04 13:10:06 得分 20
1、在VC中包含DLL的头文件;
2、在连接选项里设置LIB;
3、将DLL考到EXE目录下;
4、直接调用DLL的函数。
或用LoadLibrary动态调用,看MSDN MFC的例子。Top
2 楼flyelf(空谷清音)回复于 2006-06-04 13:25:52 得分 40
typedef NTSTATUS (WINAPI *PNTQUERYSYSTEMINFORMATION)(SYSTEM_INFORMATION_CLASS,PVOID,ULONG,PULONG);
PNTQUERYSYSTEMINFORMATION pNtQuerySystemInformation = (PNTQUERYSYSTEMINFORMATION) GetProcAddress(GetModuleHandle("ntdll.dll"), "NtQuerySystemInformation");
pNtQuerySystemInformatio(...);Top
3 楼xiaoyuzi(小鱼子)回复于 2006-06-04 13:27:02 得分 40
typedef LONG (WINAPI *PROCNTQSI)(UINT,PVOID,ULONG,PULONG);
PROCNTQSI NtQuerySystemInformation;
NtQuerySystemInformation = (PROCNTQSI)GetProcAddress(
GetModuleHandle("ntdll"),
"NtQuerySystemInformation"
);
if (!NtQuerySystemInformation)
{
return;
}
// get number of processors in the system
status = NtQuerySystemInformation(SystemBasicInformation,
&SysBaseInfo,sizeof(SysBaseInfo),NULL);
if (status != NO_ERROR)
{
return;
}
status = NtQuerySystemInformation(SystemTimeInformation,
&SysTimeInfo,sizeof(SysTimeInfo),0);
if (status!=NO_ERROR)
{
return;
}
// get new CPU''s idle time
status = NtQuerySystemInformation(SystemPerformanceInformation,
&SysPerfInfo,sizeof(SysPerfInfo),NULL);
if (status != NO_ERROR)
{
return;
}Top
4 楼xiehuanxie(xiehuanxie)回复于 2006-06-04 18:59:16 得分 0
谢谢各位.
VB中的ByVal很难理解,是传值?Top




