// ***************************************************************
// mian version: 1.0 ? date: 12/17/2006
// -------------------------------------------------------------
// 探测USB盘
// -------------------------------------------------------------
// Copyright (C) 2006 - All Rights Reserved
// ***************************************************************
//
// ***************************************************************
#include <windows.h>
#include <stdio.h>
BOOL bDriver[27];
BOOL bFirst=TRUE;
void dect()
{
char szDriver[3];
for ( int i='C';i<='Z';i++)
{
szDriver[0]=i;
szDriver[1]=':';
szDriver[2]=0;
UINT uType=GetDriveType(szDriver);
if (uType==DRIVE_REMOVABLE || uType ==DRIVE_FIXED)
{
if ((!bFirst)&&(!bDriver[i-'C'])) printf( "found %c:/n",i);
bDriver[i-'C']=TRUE;
}
else //移走?
{
if (bDriver[i-'C'])
{
bDriver[i-'C']= FALSE;
printf( "remove %c:/n",i);
}
}
}
if (bFirst) bFirst= FALSE;
}
int main()
{
ZeroMemory(bDriver, sizeof(bDriver));
while (1)
{
dect();
Sleep(2000);
}
return 0;
}
// mian version: 1.0 ? date: 12/17/2006
// -------------------------------------------------------------
// 探测USB盘
// -------------------------------------------------------------
// Copyright (C) 2006 - All Rights Reserved
// ***************************************************************
//
// ***************************************************************
#include <windows.h>
#include <stdio.h>
BOOL bDriver[27];
BOOL bFirst=TRUE;
void dect()
{
char szDriver[3];
for ( int i='C';i<='Z';i++)
{
szDriver[0]=i;
szDriver[1]=':';
szDriver[2]=0;
UINT uType=GetDriveType(szDriver);
if (uType==DRIVE_REMOVABLE || uType ==DRIVE_FIXED)
{
if ((!bFirst)&&(!bDriver[i-'C'])) printf( "found %c:/n",i);
bDriver[i-'C']=TRUE;
}
else //移走?
{
if (bDriver[i-'C'])
{
bDriver[i-'C']= FALSE;
printf( "remove %c:/n",i);
}
}
}
if (bFirst) bFirst= FALSE;
}
int main()
{
ZeroMemory(bDriver, sizeof(bDriver));
while (1)
{
dect();
Sleep(2000);
}
return 0;
}