Hi,

I have a custom action which creates a link (shortcut).

The calling process between layers is:

a)      The function of creating link is implemented in a C++ DLL. It uses 
IPersistFile::Save to save the link.

b)      The function is wrapped in C# code using P/invoke.

c)       My C# custom action calls this wrapped function to create the link.

Right now the log always reports IPersistFile::Save always return 0x8007007b 
(-2147024773) which means the path is not correct.

I have already succeeded to create a link using the same C++ dll and a managed 
standalone exe (using p/invoke too). Also I have tested that the parameter 
passing has no problem. For example, I passed in "c:\np.lnk" then I can see the 
C++ function can return the same string which is printed in msi log. I don't 
think it is permission issue because (a) I always run the msi in an admin 
command window, (b) I tried "impersonate='no'", (c) the link is created just 
under "c:\" instead of any privileged locations .

Based on my test, I suspect that IPersistFile::Save may not be used in an 
installer like a standalone managed exe.

What I am doing wrong with below code?

    hr = CoCreateInstance(CLSID_ShellLink,
        NULL,
        CLSCTX_INPROC_SERVER,
        IID_IShellLinkW,
        (LPVOID*)&psl);

    psl->SetPath(lpszTargetPath); // lpszTargetPath is 
"c:\windows\system32\notepad.exe"

    hr = psl->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf);

    hr = ppf->Save(lpszShortcutPath, TRUE); // return 0x8007007b. 
lpszShortcutPath is "c:\np.lnk"

Appreciate any insight.


Thanks
Lian
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to