|
// 通常切断
BOOL LboxWNet::DisConnect(LboxString *LName, BOOL bKeep)
{
return LboxWNet::DisConnect(
LName->szLboxString,
bKeep
);
}
BOOL LboxWNet::DisConnect(LPTSTR lpName, BOOL bKeep)
{
return LboxWNet::DisConnect(
lpName,
bKeep,
false
);
}
// 汎用
BOOL LboxWNet::DisConnect(LboxString *LName, BOOL bKeep, BOOL bForce)
{
return LboxWNet::DisConnect(
LName->szLboxString,
bKeep,
bForce
);
}
BOOL LboxWNet::DisConnect(LPTSTR lpName, BOOL bKeep, BOOL bForce)
{
if ( this->lib == NULL ) {
return false;
}
LPFUNC_WNetCancelConnection2A DllWNetCancelConnection;
DllWNetCancelConnection =
(LPFUNC_WNetCancelConnection2A)GetProcAddress(
lib, "WNetCancelConnection2A"
);
if ( DllWNetCancelConnection == NULL ) {
return false;
}
DWORD dwRet;
DWORD dwKeep;
if ( bKeep ) {
dwKeep = 0;
}
else {
dwKeep = CONNECT_UPDATE_PROFILE;
}
dwRet = DllWNetCancelConnection(
lpName,
dwKeep,
bForce
);
this->ErrorDescription.SetChar( 0, 0 );
if ( dwRet == NO_ERROR ) {
return true;
}
switch( dwRet ) {
case ERROR_BAD_PROFILE:
this->ErrorDescription.operator = (
"ユーザープロファイルの形式が正しくありません"
);
break;
case ERROR_CANNOT_OPEN_PROFILE:
this->ErrorDescription.operator = (
"ユーザープロファイルを開くことができません"
);
break;
case ERROR_DEVICE_IN_USE:
this->ErrorDescription.operator = (
"デバイスがアクティブなプロセス"
"によって使用中のため切断できません"
);
break;
case ERROR_EXTENDED_ERROR:
this->ErrorDescription.operator = (
"ネットワーク固有のエラーが発生しました"
);
break;
case ERROR_NOT_CONNECTED:
this->ErrorDescription.operator = (
"デバイスが無効です"
);
break;
case ERROR_OPEN_FILES:
this->ErrorDescription.operator = (
"開いているファイルがあるので切断できません"
);
break;
}
return false;
}
| |