diff options
| author | Simon Rettberg | 2016-03-04 18:07:09 +0100 |
|---|---|---|
| committer | Simon Rettberg | 2016-03-04 18:07:09 +0100 |
| commit | cd8ccf76f798a553893d3223fdf5c95c3fa5d40c (patch) | |
| tree | 1e7ae0d9846fdd46ed2e56e7d6efdff9623edbf5 /remote | |
| parent | [run-virt/vmware] Mount home directory in windows (first working version) (diff) | |
| download | tm-scripts-cd8ccf76f798a553893d3223fdf5c95c3fa5d40c.tar.gz tm-scripts-cd8ccf76f798a553893d3223fdf5c95c3fa5d40c.tar.xz tm-scripts-cd8ccf76f798a553893d3223fdf5c95c3fa5d40c.zip | |
[run-virt] Fix mapping of drive letter, shortcut on desktop
Diffstat (limited to 'remote')
| -rwxr-xr-x | remote/modules/run-virt/data/opt/openslx/vmchooser/data/openslx.exe | bin | 52224 -> 52224 bytes | |||
| -rw-r--r-- | remote/modules/run-virt/winres.c | 28 |
2 files changed, 17 insertions, 11 deletions
diff --git a/remote/modules/run-virt/data/opt/openslx/vmchooser/data/openslx.exe b/remote/modules/run-virt/data/opt/openslx/vmchooser/data/openslx.exe Binary files differindex 387f420b..39928c92 100755 --- a/remote/modules/run-virt/data/opt/openslx/vmchooser/data/openslx.exe +++ b/remote/modules/run-virt/data/opt/openslx/vmchooser/data/openslx.exe diff --git a/remote/modules/run-virt/winres.c b/remote/modules/run-virt/winres.c index 0cc3963b..54c0ad1b 100644 --- a/remote/modules/run-virt/winres.c +++ b/remote/modules/run-virt/winres.c @@ -53,7 +53,7 @@ static BOOL mountNetworkShares(); static int queryPasswordDaemon(); static BOOL fileExists(wchar_t* szPath); -static HRESULT createFolderShortcut(wchar_t* sTargetfile, wchar_t* sLinkfile); +static HRESULT createFolderShortcut(wchar_t* sTargetfile, wchar_t* sLinkfile, wchar_t* comment); static void alog(const char *fmt, ...) { @@ -525,9 +525,6 @@ static void udpReceived(SOCKET sock) static DWORD mount(LPNETRESOURCEW share, LPWSTR pass, LPWSTR user) { DWORD retval; - // Remove remembered drive if it's not connected - //GetDriveType() DRIVE_NO_ROOT_DIR - //WNetCancelConnection2W(share->lpLocalName, CONNECT_UPDATE_PROFILE, TRUE); // Now try to mount retval = WNetAddConnection2W(share, pass, user, CONNECT_TEMPORARY | CONNECT_CURRENT_MEDIA); if (retval == NO_ERROR) { @@ -550,7 +547,7 @@ static DWORD mount(LPNETRESOURCEW share, LPWSTR pass, LPWSTR user) return retval; } -static void mkshortcut(const netdrive_t *d) +static void mkshortcut(const netdrive_t *d, wchar_t *comment) { if (d->shortcut == NULL || strlen(d->shortcut) == 0) return; @@ -560,7 +557,7 @@ static void mkshortcut(const netdrive_t *d) MultiByteToWideChar(CP_UTF8, 0, d->path, -1, tmp, MAX_PATH); StringCchPrintfW(wTarget, MAX_PATH, L"\"%s\"", tmp); DeleteFileW(wShortcut); - createFolderShortcut(wTarget, wShortcut); + createFolderShortcut(wTarget, wShortcut, comment); } static BOOL mountNetworkShare(const netdrive_t *d) @@ -591,15 +588,21 @@ static BOOL mountNetworkShare(const netdrive_t *d) share.lpRemoteName = path; share.lpProvider = NULL; letter[1] = ':'; - letter[2] = 0; // TODO d->shortcut + letter[2] = 0; + letter[3] = 0; if (letter[0] != 0) { // Try with specific letter // Get anything there might be out of the way WNetCancelConnection2W(letter, CONNECT_UPDATE_PROFILE, TRUE); + WNetCancelConnection2W(letter, 0, TRUE); + letter[2] = '\\'; + WNetCancelConnection2W(letter, 0, TRUE); + DeleteVolumeMountPointW(letter); + letter[2] = 0; // Connect defined share retval = mount(&share, pass, user); if (retval == NO_ERROR) { - mkshortcut(d); + mkshortcut(d, letter); return TRUE; } if (retval != ERROR_ALREADY_ASSIGNED && retval != ERROR_DEVICE_ALREADY_REMEMBERED @@ -615,7 +618,7 @@ static BOOL mountNetworkShare(const netdrive_t *d) || retval == ERROR_CONNECTION_UNAVAIL) continue; if (retval == NO_ERROR) { - mkshortcut(d); + mkshortcut(d, letter); return TRUE; } alog("mountNetworkShare: without letter failed: %d", (int)retval); @@ -688,7 +691,7 @@ static uint8_t* hex2bin(char *szHexString) // Stuff for creating a simple shortcut (.lnk) -static HRESULT createFolderShortcut(wchar_t* targetDir, wchar_t* linkFile) +static HRESULT createFolderShortcut(wchar_t* targetDir, wchar_t* linkFile, wchar_t* comment) { HRESULT hRes; /* Returned COM result code */ IShellLink* pShellLink; /* IShellLink object pointer */ @@ -709,8 +712,11 @@ static HRESULT createFolderShortcut(wchar_t* targetDir, wchar_t* linkFile) wchar_t explorer[MAX_PATH]; StringCchPrintfW(explorer, MAX_PATH, L"\"%s\\explorer.exe\"", windowsPath); /* Set the fields in the IShellLink object */ - //hRes = pShellLink->lpVtbl->SetPath(pShellLink, targetDir); + hRes = pShellLink->lpVtbl->SetPath(pShellLink, explorer); hRes = pShellLink->lpVtbl->SetArguments(pShellLink, targetDir); + if (comment != NULL) { + hRes = pShellLink->lpVtbl->SetDescription(pShellLink, comment); + } /* Use the IPersistFile object to save the shell link */ hRes = pShellLink->lpVtbl->QueryInterface( |
