怎么利用VC++读取U盘物理序列号
1个回答
2017-05-31
展开全部
取U盘盘符代码使用delphi程序实现U盘盘符获取其实难procedure TForm1.Button1Click(Sender: TObject);var
buf:array [0..MAX_PATH-1] of char;
m_Result:Integer;
i:Integer;
str_temp:string;
begin
m_Result:=GetLogicalDriveStrings(MAX_PATH,buf);
for i:=0 to (m_Result div 4) do
begin
str_temp:=string(buf[i*4]+buf[i*4+1]+buf[i*4+2]);
if GetDriveType(pchar(str_temp)) = DRIVE_REMOVABLE then
begin
ShowMessage(str_temp+''盘U盘'');
ListBox1.Items.Add(str_temp);
end;
end;
end;磁盘类型量参考DRIVE_UNKNOWN = 0;
{$EXTERNALSYM DRIVE_UNKNOWN}
DRIVE_NO_ROOT_DIR = 1;
{$EXTERNALSYM DRIVE_NO_ROOT_DIR}
DRIVE_REMOVABLE = 2;
{$EXTERNALSYM DRIVE_REMOVABLE}
buf:array [0..MAX_PATH-1] of char;
m_Result:Integer;
i:Integer;
str_temp:string;
begin
m_Result:=GetLogicalDriveStrings(MAX_PATH,buf);
for i:=0 to (m_Result div 4) do
begin
str_temp:=string(buf[i*4]+buf[i*4+1]+buf[i*4+2]);
if GetDriveType(pchar(str_temp)) = DRIVE_REMOVABLE then
begin
ShowMessage(str_temp+''盘U盘'');
ListBox1.Items.Add(str_temp);
end;
end;
end;磁盘类型量参考DRIVE_UNKNOWN = 0;
{$EXTERNALSYM DRIVE_UNKNOWN}
DRIVE_NO_ROOT_DIR = 1;
{$EXTERNALSYM DRIVE_NO_ROOT_DIR}
DRIVE_REMOVABLE = 2;
{$EXTERNALSYM DRIVE_REMOVABLE}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询