View Full Version : Errors including shellapi.h
SkripT
1st May 2006, 15:02
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.
Dark_Tower
1st May 2006, 15:09
Try including the files "qt_windows.h" and "qtwindowdefs_win.h", too
zlatko
1st May 2006, 15:09
It can contain many other declaration and headers so I dont think that you need it..:rolleyes:
What about QProcess ?
SkripT
1st May 2006, 15:27
It can contain many other declaration and headers so I dont think that you need it..:rolleyes:
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:
if ((long)ShellExecute(0, QString("open").utf16(), pathDocument.utf16(), NULL, NULL,
SW_SHOWNORMAL) <= 32)
QMessageBox::critical(this, "Pre-Visualització", "Error opening file");
"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?
SkripT
1st May 2006, 17:07
Any suggestions, plz? :(
Chicken Blood Machine
1st May 2006, 17:08
Use ShellExecuteW() instead. It is the wide character version of the call.
SkripT
1st May 2006, 17:36
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?
Chicken Blood Machine
1st May 2006, 17:55
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:
if ((long)ShellExecute(0, 0, reinterpret_cast<WCHAR*>(pathDocument.utf16()), 0, 0, SW_SHOWNORMAL) <= 32)
QMessageBox::critical(this, "Pre-Visualització", "Error opening file");
p.s. You don't need the second argument. You can leave it as NULL
SkripT
1st May 2006, 18:13
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*.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.