CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    May 2001
    Location
    Madrid-Spain
    Posts
    1,123

    Question ShellExecute & XP & lnk files

    Hi!

    This is my code:
    Code:
    if (::ShellExecute(NULL, "open", sPath, NULL, NULL, SW_SHOWNORMAL) <= (HINSTANCE)32)
    {
    	ShowError(IDS_ERROR_OPEN_FILE, sPath);
    	bRetcode = FALSE;
    }
    In windows 95/98/NT/2000 works perfectly. In XP fails when sPath is a lnk file. But only in some machines with XP. Anybody know why?

    Thank you in advance.
    I am Miss Maiden... Miss Iron Maiden :-D

  2. #2
    Join Date
    Aug 2001
    Location
    Stockholm, Sweden
    Posts
    1,664
    No, I don't know why.

    What error value does ShellExecute return?

    You say it works on same machines... is this maybe a problem with user-rights (logon with a user the belongs to the local admin group).

  3. #3
    Join Date
    May 2001
    Location
    Madrid-Spain
    Posts
    1,123
    Thank you for your answer!

    Well, I don't know what is the error, because I don't have the machine, and on my machine works
    Moreover, if you do double-click in the lnk file from explorer, it works, but not from code. And I suppose user-rights are the same in both cases, aren't they?
    I am Miss Maiden... Miss Iron Maiden :-D

  4. #4
    Join Date
    May 2001
    Location
    Madrid-Spain
    Posts
    1,123
    More info:

    We have tested in 3 XP machines:

    1.- It works.
    2.- ShellExecute doesn't return any error, but it doesn't open the file.
    3.- ShellExecute returns an error, I know it because the error message is shown, but I don't know how is the error.

    And in the 3 cases the file can be opened from Windows Explorer.
    Any ideas?
    I am Miss Maiden... Miss Iron Maiden :-D

  5. #5
    Join Date
    Apr 2005
    Posts
    1

    Re: ShellExecute & XP & lnk files

    I found this post. I am having the same problem with a program of mine. A user reported the error and I was able to reproduce it on my XP SP2 machine but on another it does not happen. I am sure that it used to not happen on this machine either. On another XP just upgraded to SP2 machine it does not happen.

    Has anyone found a solution. The cause seems like it may be an update to windows, or at least that seems like the next logical thing to look into.

    I'd appreciate any information you can provide.

    Thanks,
    Jon Kuhn

  6. #6
    Join Date
    Mar 2002
    Posts
    350

    Re: ShellExecute & XP & lnk files

    One selution is to resolve the lnk and pass the real path to ShellExecute.
    And use ShellExecuteEx instead to GetLastError().

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured