Results 1 to 9 of 9

Thread: Errors including shellapi.h

  1. #1
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Errors including shellapi.h

    Hi all, in my Qt application I need to call to ShellExecute so I have to include the file shellapi.h. the problem is that when I try to compile only including <shellapi.h> file it give me the errors shown in the image that I attach. Could somebody explain me what I'm doing wrong? Thanks.
    Attached Images Attached Images

  2. #2
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    38
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Errors including shellapi.h

    Try including the files "qt_windows.h" and "qtwindowdefs_win.h", too

  3. The following user says thank you to Dark_Tower for this useful post:

    SkripT (1st May 2006)

  4. #3
    Join Date
    Jan 2006
    Location
    Ukraine,Lviv
    Posts
    454
    Thanks
    9
    Thanked 27 Times in 27 Posts
    Qt products
    Qt3
    Platforms
    Unix/X11 Windows

    Default Re: Errors including shellapi.h

    It can contain many other declaration and headers so I dont think that you need it..
    What about QProcess ?
    a life without programming is like an empty bottle

  5. #4
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Errors including shellapi.h

    Quote Originally Posted by zlatko
    It can contain many other declaration and headers so I dont think that you need it..
    What about QProcess ?
    Including the files that Dark_Tower comented has solved the errors mentioned. zlatko I need ShellExecute because I have to open a doument (PDF) with the default application from the system and everywhere I aked for how to do it, they syggested me to use ShellExecute... Now I've got some other strange errors. My code is the following:
    Qt Code:
    1. if ((long)ShellExecute(0, QString("open").utf16(), pathDocument.utf16(), NULL, NULL,
    2. SW_SHOWNORMAL) <= 32)
    3. QMessageBox::critical(this, "Pre-Visualització", "Error opening file");
    To copy to clipboard, switch view to plain text mode 

    "pathDocument" contains the path to the PDF doc that I want to open. The compiling errors are shown in the new image that I attach . Could somebody please explain me where's the mistake?
    Attached Images Attached Images

  6. #5
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Errors including shellapi.h

    Any suggestions, plz?

  7. #6
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Errors including shellapi.h

    Use ShellExecuteW() instead. It is the wide character version of the call.
    Save yourself some pain. Learn C++ before learning Qt.

  8. #7
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Errors including shellapi.h

    Quote Originally Posted by Chicken Blood Machine
    Use ShellExecuteW() instead. It is the wide character version of the call.
    thanks for the suggestion Chicken Blood Machine but it continues giving me the same weird errors

    More suggestions, please?
    Last edited by SkripT; 1st May 2006 at 17:48.

  9. #8
    Join Date
    Jan 2006
    Location
    Mountain View, CA
    Posts
    279
    Thanked 42 Times in 37 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Errors including shellapi.h

    Quote Originally Posted by SkripT
    thanks for the suggestion Chicken Blood Machine but it continues giving me the same weird errors

    More suggestions, please?
    Then try explicitly casting, e.g:

    Qt Code:
    1. if ((long)ShellExecute(0, 0, reinterpret_cast<WCHAR*>(pathDocument.utf16()), 0, 0, SW_SHOWNORMAL) <= 32)
    2. QMessageBox::critical(this, "Pre-Visualització", "Error opening file");
    To copy to clipboard, switch view to plain text mode 

    p.s. You don't need the second argument. You can leave it as NULL
    Save yourself some pain. Learn C++ before learning Qt.

  10. The following user says thank you to Chicken Blood Machine for this useful post:

    SkripT (1st May 2006)

  11. #9
    Join Date
    Jan 2006
    Location
    Catalonia
    Posts
    266
    Thanks
    44
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default [SOLVED] Errors including shellapi.h

    Finally works!!!!! Thanks Chicken Blood Machine one more time. The only think that I needed to change from your version was reinterpret_cast<WCHAR*> for reinterpret_cast<const WCHAR*> because QString::utf16 returns a const ushort*.
    Last edited by SkripT; 1st May 2006 at 18:27.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.