Пример #1
0
bool DriveLocalToRemoteName(int DriveType, wchar_t Letter, string &strDest)
{
	bool NetPathShown=false, IsOK=false;
	wchar_t LocalName[8]=L" :\0\0\0";
	string strRemoteName;

	*LocalName=Letter;
	strDest.clear();

	if (DriveType == DRIVE_UNKNOWN)
	{
		LocalName[2]=L'\\';
		DriveType = FAR_GetDriveType(LocalName);
		LocalName[2]=0;
	}

	if (IsDriveTypeRemote(DriveType))
	{
		DWORD res = api::WNetGetConnection(LocalName,strRemoteName);

		if (res == NO_ERROR || res == ERROR_CONNECTION_UNAVAIL)
		{
			NetPathShown=true;
			IsOK=true;
		}
	}

	if (!NetPathShown && GetSubstName(DriveType, LocalName, strRemoteName))
		IsOK=true;

	if (IsOK)
		strDest = strRemoteName;

	return IsOK;
}
Пример #2
0
bool DelSubstDrive(const wchar_t *DeviceName)
{
	bool Result=false;
	string strTargetPath;

	if (GetSubstName(DRIVE_NOT_INIT,DeviceName,strTargetPath))
	{
		strTargetPath=(string)L"\\??\\"+strTargetPath;
		Result=(DefineDosDevice(DDD_RAW_TARGET_PATH|DDD_REMOVE_DEFINITION|DDD_EXACT_MATCH_ON_REMOVE,DeviceName,strTargetPath)==TRUE);
	}

	return Result;
}