 |
|
 |
Modifying the shell link target of an existing shortcut by loading the shortcut, calling SetPath and saving the target did not work because of this section of code in Save():
//Set the various link values
if (m_sli.m_pidl)
{
hRes = m_psl->SetIDList(m_sli.m_pidl);
if (!SUCCEEDED(hRes))
TRACE(_T("CShellLink::Save, Failed in call to IShellLink::SetIDList, HRESULT was %x\n"), hRes);
}
else
{
hRes = m_psl->SetPath(m_sli.m_sTarget);
if (!SUCCEEDED(hRes))
TRACE(_T("CShellLink::Save, Failed in call to IShellLink::SetPath, HRESULT was %x\n"), hRes);
}
Which I modified to:
//Set the various link values
if (m_sli.m_pidl)
{
hRes = m_psl->SetIDList(m_sli.m_pidl);
if (!SUCCEEDED(hRes))
TRACE(_T("CShellLink::Save, Failed in call to IShellLink::SetIDList, HRESULT was %x\n"), hRes);
}
// else
//{
hRes = m_psl->SetPath(m_sli.m_sTarget);
if (!SUCCEEDED(hRes))
TRACE(_T("CShellLink::Save, Failed in call to IShellLink::SetPath, HRESULT was %x\n"), hRes);
//}
Now seems to work as expected.
|
|
|
|
 |
|
 |
I want to create a shortcut to a dial-up connection on the desktop using VB code..
even some other language it doesn't matter..
neet art..
|
|
|
|
 |
|
 |
In your code:
CString CShellLink::GetArguments() const
{
return m_sli.m_sTarget;
}
Should it return m_sli.m_sArguments?
Other than that, excellent article.
|
|
|
|
 |
|
 |
Just to let you know that I have updated the release on my web site (www.naughter.com) to address this problem.
|
|
|
|
 |
|
|
 |
|
 |
Create one yourself, then examine the shortcut (lnk file) using say any text editor to examine it's contents. From memory I think the target is something like "{GUID of Control Panel}".
|
|
|
|
 |
|
 |
Hi there,
Is there any way out to create the shortcut to the DUN on the desktop? If there then do let me know.
Thanx,
Paras
|
|
|
|
 |
|
 |
See my previous reply on creating a shortcut to a control panel applet.
|
|
|
|
 |
|
 |
I cannot seem to get the m_nShowCmd to work. I assign set it to SW_MINIMIZE and it creates the .lnk file okay. Only the show is normal when looking at the properties. -Thanks, Mike
|
|
|
|
 |
|
 |
Okay, just for those who don't know. I found that SW_SHOWMINNOACTIVE is required for m_nShowCmd when you want the program to be minimized. You would think that since SW_MAXIMIZE is for maximized then SW_MINIMIZE would be for minimized. Nope, use SW_SHOWMINNOACTIVE or value of 7 Thanks, Mike
|
|
|
|
 |
|
 |
original code:
//Set the various arguments
HRESULT hRes = m_psl->SetWorkingDirectory(m_sli.m_sTarget);
if (!SUCCEEDED(hRes))
TRACE(_T("CUrlShellLink::Save, Failed in call to IShellLink::SetPath, HRESULT was %x\n"), hRes);
fixed one:
//Set the various arguments
HRESULT hRes = m_psl->SetPath(m_sli.m_sTarget);
if (!SUCCEEDED(hRes))
TRACE(_T("CUrlShellLink::Save, Failed in call to IShellLink::SetPath, HRESULT was %x\n"), hRes);
just the name.
Stewe
Stewe
|
|
|
|
 |
|
 |
The latest version on my web site (www.naughter.com) does not have this problem.
Regards,
|
|
|
|
 |
|
 |
CShellLink::Initialise, Failed in call to CoCreateInstance for IShellLink, HRESULT was 80004002
Stewe
|
|
|
|
 |
|
 |
Did you initialize COM in your app!
|
|
|
|
 |
|
 |
Hi,
Everytime I try to load up a shortcut the Load () function just returns false - I've tried the app on both win9x and win2k and it doesn't work on any one. These shortcuts were created using the system and not this class.
CShellLink shell_link;
shell_link.Load ("C:\\t.lnk");
traces
CShellLink::Initialise, Failed in call to CoCreateInstance for IShellLink, HRESULT was 800401f0
Andreas Philipson
|
|
|
|
 |
|
 |
I solved it... The CoInitialize () was never called .
Andreas Philipson
|
|
|
|
 |
|
 |
In am checking the functionality of ur class.
i am facing problems in using the method sethotkey.
i modified the code(using CShellLink part) in main.cpp as follows for my requirement:
/*** modefied code starts ***************/
char str[256], str1[256];
LPITEMIDLIST pidl;
SHGetSpecialFolderLocation(0, CSIDL_DESKTOP, &pidl);
SHGetPathFromIDList(pidl, str);
SHGetPathFromIDList(pidl, str1);
lstrcat(str,"\\notepad.exe");
lstrcat(str1,"\\notepad.lnk");
//Test all the functionality of the classes
//First Saving
CShellLinkInfo sli1;
sli1.m_sTarget = /*_T("notepad.exe")*/str;
// sli1.m_sArguments = _T("c:\\config.sys");
// sli1.m_sWorkingDirectory = _T("c:\\");
sli1.m_wHotkey = 0x641; // ctrl_a
sli1.m_sDescription = _T("Edit your untitled");
sli1.m_sIconLocation = _T("shell32.dll");
sli1.m_nIconIndex = 21; //Use an interesting icon
sli1.m_nShowCmd = SW_MAXIMIZE;
CShellLink sl1;
if (sl1.Create(sli1))
{
if (!sl1.Save(/*_T("c:\\Edit your untitled.lnk")*/str1))
TRACE(_T("Failed to save link\n"));
else
_tprintf(_T("A shortcut to edit your untitled had been created on you C:\\ drive\n"));
}
else
TRACE(_T("Failed to create link\n"));
_tprintf(_T("Till Next time!!!, Press any key to exit\n"));
ch = getch();
sli1.m_sTarget = /*_T("notepad.exe")*/str;
// sli1.m_sArguments = _T("c:\\config.sys");
// sli1.m_sWorkingDirectory = _T("c:\\");
sli1.m_wHotkey = 0x642; // ctrl_b
sli1.m_sDescription = _T("Edit your untitled");
sli1.m_sIconLocation = _T("shell32.dll");
sli1.m_nIconIndex = 21; //Use an interesting icon
sli1.m_nShowCmd = SW_MAXIMIZE;
// CShellLink sl1;
if (sl1.Create(sli1))
{
if (!sl1.Save(/*_T("c:\\Edit your untitled.lnk")*/str1))
TRACE(_T("Failed to save link\n"));
else
_tprintf(_T("A shortcut to edit your untitled had been created on you C:\\ drive\n"));
}
else
TRACE(_T("Failed to create link\n"));
/*** modefied code ends ***************/
Basically in this code ....
first, i create a shortcut to notepad.exe and also assign a hotkey(here ctrl+a) to invoke the target.
next wait for user to press any key....
second, i agian create the shortcut to notepad.exe and also assign a different hotkey(here ctrl+b) to invoke the target.
.....
so after first step if i press ctrl+a it invokes the target.
now after second step if i press ctrl+b it invokes the target.
fine.
now if i press crtl+a (which actaully i chagned to ctrl+b) it invokes the target-->Problem.
i want to modify the hotkey of the shorcut in the above source code...
when i modify, only the new hotkey should invoke the target.
and the old hotkey can be reassinged to someother shorcuts..
how can i do that????????
any suggestions...????
|
|
|
|
 |