|
// *********************************************************
// ディスク資源ダイアログ接続
// 戻り値 : true 成功, false 失敗
// *********************************************************
BOOL LboxWNet::DialogConnect( HWND hOwner )
{
if ( this->lib == NULL ) {
return false;
}
LPFUNC_WNetConnectionDialog1A DllWNetConnectionDialog;
DllWNetConnectionDialog =
(LPFUNC_WNetConnectionDialog1A)GetProcAddress(
lib, "WNetConnectionDialog1A"
);
if ( DllWNetConnectionDialog == NULL ) {
return false;
}
NETRESOURCE nr;
ZeroMemory( &nr, sizeof(NETRESOURCE) );
nr.dwType = RESOURCETYPE_DISK;
nr.lpLocalName = NULL;
nr.lpRemoteName = NULL;
nr.lpProvider = NULL;
CONNECTDLGSTRUCT cds;
ZeroMemory( &cds, sizeof( CONNECTDLGSTRUCT ) );
cds.cbStructure = sizeof( CONNECTDLGSTRUCT );
cds.hwndOwner = hOwner;
cds.lpConnRes = &nr;
cds.dwFlags = CONNDLG_USE_MRU;
DWORD dwRet;
dwRet = DllWNetConnectionDialog(
&cds
);
this->AccessName.SetChar( 0, 0 );
this->ErrorDescription.SetChar( 0, 0 );
if ( dwRet == NO_ERROR ) {
if ( cds.dwDevNum == 0 ) {
return false;
}
this->AccessName.SetChar( 2, 0 );
this->AccessName.SetChar( 1, ':' );
this->AccessName.SetChar( 0, 0x40 + cds.dwDevNum );
return true;
}
switch( dwRet ) {
case 0xFFFFFFFF:
this->ErrorDescription.operator = (
"ダイアログ処理はキャンセルされました"
);
break;
case ERROR_INVALID_PARAMETER:
this->ErrorDescription.operator = (
"パラメータに誤りがあります"
);
break;
case ERROR_BAD_DEV_TYPE:
this->ErrorDescription.operator = (
"ディスクタイプに設定されていません"
);
break;
case ERROR_BUSY:
this->ErrorDescription.operator = (
"ネットワークプロバイダがビジーです"
);
break;
case ERROR_NO_NETWORK:
this->ErrorDescription.operator = (
"ネットワークに接続されていません"
);
break;
case ERROR_NOT_ENOUGH_MEMORY:
this->ErrorDescription.operator = (
"ダイアログボックスを表示するための"
"十分なメモリがありません"
);
break;
case ERROR_EXTENDED_ERROR:
this->ErrorDescription.operator = (
"ネットワーク固有のエラーが発生しました"
);
break;
}
return false;
}
| |