Creating Desktop Shortcut - xharbour
This is a discussion on Creating Desktop Shortcut - xharbour ; Hi,
Is it possible to create a program's desktop shortcut with console
application? I want to create a windows desktop shortcut from a remote
terminal without end users intervention.
Thanks for any help...
Mario...
-
Creating Desktop Shortcut
Hi,
Is it possible to create a program's desktop shortcut with console
application? I want to create a windows desktop shortcut from a remote
terminal without end users intervention.
Thanks for any help...
Mario
-
Re: Creating Desktop Shortcut
On 10 dez, 22:57, "Mario H. Sabado" <mhsab...@gmail.com> wrote:
> Hi,
>
> Is it possible to create a program's desktop shortcut with console
> application? I want to create a windows desktop shortcut from a remote
> terminal without end users intervention.
>
> Thanks for any help...
>
> Mario
copy shortcut archive to your client
-
Re: Creating Desktop Shortcut
Hi Mario
I'm not sure if this helps but here is a C wrapper for creating a shortcut.
I think it works, I didn't write it.
CreateShellLink(targetPath, linkPath, workingPath, description, iconpath,
iconindex, arguments)
HB_FUNC(CREATESHELLLINK)
{
HRESULT hr = E_FAIL;
LPCTSTR lpszArguments = hb_parc(7);
LPCTSTR lpszDescription = hb_parc(4);
int nIconIndex = hb_parnl(6);
LPCTSTR lpszIconPath = hb_parc(5);
LPCTSTR lpszLinkPath = hb_parc(2);
LPCTSTR lpszTargetPath = hb_parc(1);
LPCTSTR lpszWorkingPath = hb_parc(3);
WCHAR wszAnsiLinkPath[MAX_PATH] = {0};
HRESULT hrCoInit = E_FAIL;
IPersistFile* pPersistFile = NULL;
IShellLink* pShellLink = NULL;
hrCoInit = CoInitialize(NULL);
hr = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
&IID_IShellLink, (void**) &pShellLink);
if (SUCCEEDED(hr))
{
hr = pShellLink->lpVtbl->QueryInterface(pShellLink, &IID_IPersistFile,
(void**) &pPersistFile);
if (SUCCEEDED(hr))
{
pShellLink->lpVtbl->SetArguments(pShellLink, lpszArguments);
pShellLink->lpVtbl->SetDescription(pShellLink, lpszDescription);
pShellLink->lpVtbl->SetIconLocation(pShellLink, lpszIconPath,
nIconIndex);
pShellLink->lpVtbl->SetPath(pShellLink, lpszTargetPath);
pShellLink->lpVtbl->SetWorkingDirectory(pShellLink,
lpszWorkingPath);
MultiByteToWideChar(CP_ACP, 0, lpszLinkPath, -1, wszAnsiLinkPath,
sizeof(wszAnsiLinkPath) / sizeof(wszAnsiLinkPath[0]));
hr = pPersistFile->lpVtbl->Save(pPersistFile, wszAnsiLinkPath,
TRUE);
pPersistFile->lpVtbl->Release(pPersistFile);
}
pShellLink->lpVtbl->Release(pShellLink);
}
if (SUCCEEDED(hrCoInit))
CoUninitialize();
hb_retnl(SUCCEEDED(hr) ? 0 : hr);
-
Re: Creating Desktop Shortcut
Thanks Nick! Will try this out...
Regards,
Mario
Nick Hilder wrote:
> Hi Mario
>
> I'm not sure if this helps but here is a C wrapper for creating a shortcut.
> I think it works, I didn't write it.
>
> CreateShellLink(targetPath, linkPath, workingPath, description, iconpath,
> iconindex, arguments)
>
> HB_FUNC(CREATESHELLLINK)
> {
> HRESULT hr = E_FAIL;
>
> LPCTSTR lpszArguments = hb_parc(7);
> LPCTSTR lpszDescription = hb_parc(4);
> int nIconIndex = hb_parnl(6);
> LPCTSTR lpszIconPath = hb_parc(5);
> LPCTSTR lpszLinkPath = hb_parc(2);
> LPCTSTR lpszTargetPath = hb_parc(1);
> LPCTSTR lpszWorkingPath = hb_parc(3);
>
> WCHAR wszAnsiLinkPath[MAX_PATH] = {0};
> HRESULT hrCoInit = E_FAIL;
> IPersistFile* pPersistFile = NULL;
> IShellLink* pShellLink = NULL;
>
> hrCoInit = CoInitialize(NULL);
> hr = CoCreateInstance(&CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER,
> &IID_IShellLink, (void**) &pShellLink);
> if (SUCCEEDED(hr))
> {
> hr = pShellLink->lpVtbl->QueryInterface(pShellLink, &IID_IPersistFile,
> (void**) &pPersistFile);
> if (SUCCEEDED(hr))
> {
> pShellLink->lpVtbl->SetArguments(pShellLink, lpszArguments);
> pShellLink->lpVtbl->SetDescription(pShellLink, lpszDescription);
> pShellLink->lpVtbl->SetIconLocation(pShellLink, lpszIconPath,
> nIconIndex);
> pShellLink->lpVtbl->SetPath(pShellLink, lpszTargetPath);
> pShellLink->lpVtbl->SetWorkingDirectory(pShellLink,
> lpszWorkingPath);
>
> MultiByteToWideChar(CP_ACP, 0, lpszLinkPath, -1, wszAnsiLinkPath,
> sizeof(wszAnsiLinkPath) / sizeof(wszAnsiLinkPath[0]));
>
> hr = pPersistFile->lpVtbl->Save(pPersistFile, wszAnsiLinkPath,
> TRUE);
>
> pPersistFile->lpVtbl->Release(pPersistFile);
> }
>
> pShellLink->lpVtbl->Release(pShellLink);
> }
>
> if (SUCCEEDED(hrCoInit))
> CoUninitialize();
>
> hb_retnl(SUCCEEDED(hr) ? 0 : hr);
>
>
Similar Threads
-
By Application Development in forum DOTNET
Replies: 2
Last Post: 11-26-2007, 03:54 AM
-
By Application Development in forum labview
Replies: 1
Last Post: 11-12-2007, 11:10 AM
-
By Application Development in forum Java
Replies: 2
Last Post: 12-25-2005, 12:01 PM
-
By Application Development in forum basic.visual
Replies: 1
Last Post: 01-26-2004, 11:13 AM
-
By Application Development in forum basic.visual
Replies: 0
Last Post: 01-26-2004, 06:27 AM