谁有时间写个GetLogicalDrivers使用的例子

ttpps 2006-12-11 03:12:10
调用一下kernel32.DLL中GetLogicalDrivers
感谢了
...全文
196 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
ReverseEngineering 2006-12-22
  • 打赏
  • 举报
回复
学习一下。
ttpps 2006-12-11
  • 打赏
  • 举报
回复
1.头文件有些什么?
2.kernel32.DLL怎么引用的,如何找到GetLogicalDrives()的入口地址的?
3.我现在在学C#对C++的库使用的不是太多,所以该用些什么.H文件不是太了解!
4.下面是我在C++(VC6.0下 windows sp)的代码(API高手有空帮忙看):
#include<stdio.h>
#include<string.h>
#include<iostream.h>
#define DWORD unsigned int
int main()
{
DWORD drives;

int x;

[DllImport("kernel32.DLL", EntryPoint = "GetLogicalDrivers",SetLastError = true,CharSet=CharSet.Ansi)]
private bool DWORD GetLogicalDrives(void)

drives = GetLogicalDrives();


cout << drives;

return 0;
}
问题提示:error C2143: syntax error : missing ';' before '[' Error executing cl.exe.
hailongchang 2006-12-11
  • 打赏
  • 举报
回复
The GetLogicalDrives function returns a 32-bit value that contains one bit for each drive letter currently in use. Bit zero represents drive A. The code given below looks at each bit up through bit 25 and prints out the corresponding drive letter for each bit that contains a one.



DWORD drives;

int x;

drives = GetLogicalDrives();

CString str;

str.Format("Logical drives on this machine:\n");

//cout << "Logical drives on this machine: ";



for (x=0; x<26; x++)

{

if (drives & 1!=0)

{



CString fmt;

char ch=(char)('A'+x);

fmt.Format("%c",ch);

str+=fmt;

}

drives = drives >> 1;

}

MessageBox(str);

64,648

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧