I am trying to open a PDF file when a button is pressed using the ShellExecute() command and am having problems. I first said:
#include "Windows.h" #include <shellapi.h>
and then added later on:
private: System::Void btn2_Click(System::Object^ sender, System::EventArgs^ e) { ShellExecute(NULL, "Open", "C:\\Program Files\\My Prgram\\test1.pdf", NULL, NULL, SW_SHOWNORMAL); }
And got the following errors:
1>c:\users\raj\documents\visual studio 2010\projects\helloworld\helloworld\Form1.h(109): error C2664: 'ShellExecuteW' : cannot convert parameter 2 from 'const char [5]' to 'LPCWSTR'
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
Also, I would like the PDF file to be kept in a folder with the executable (.exe) file and the folder in which both these files are in may be moved, how would I define the directory for this?
Thanks.