PSP Coding
Would you like to react to this message? Create an account in a few clicks or log in to continue.

PSP Coding


 
HomeLatest imagesSearchRegisterLog in

 

 ShellExecute problem

Go down 
2 posters
AuthorMessage
Jellyforme




Posts : 38
Points : 63
Reputation : 1
Join date : 2010-09-30

ShellExecute problem Empty
PostSubject: ShellExecute problem   ShellExecute problem I_icon_minitimeSat Oct 02, 2010 5:58 pm

Code:

#include <iostream>
#include <Windows.h>
#include <cstdlib>
using namespace std;

void main()
{
char AnsOk[5];
cout << "Help a  person in need!\n";
cout << "To continue type ok...\n";
if(!strcmp(AnsOk, "ok"))
{
      ShellExecute (NULL, "open",

"http://www.freepsnpoints.com/?i=175427", NULL, NULL,

SW_SHOWNORMAL);
}
}
Code:

/out:converter.exe
converter.obj
converter.obj : error LNK2019: unresolved external symbol __imp__ShellExecuteA@2
4 referenced in function _main
converter.exe : fatal error LNK1120: 1 unresolved externals
I have no idea why it's doing this. Any suggestions?

Back to top Go down
-LeetGamer-
Admin



Posts : 247
Points : 397
Reputation : 4
Join date : 2010-09-29
Age : 30

ShellExecute problem Empty
PostSubject: Re: ShellExecute problem   ShellExecute problem I_icon_minitimeSat Oct 02, 2010 6:05 pm

Hmmm, those are some odd looking errors, try using int main () and not void main () and let me know what happens.
Back to top Go down
Jellyforme




Posts : 38
Points : 63
Reputation : 1
Join date : 2010-09-30

ShellExecute problem Empty
PostSubject: Re: ShellExecute problem   ShellExecute problem I_icon_minitimeSat Oct 02, 2010 6:19 pm

I got the exact same errors.
Back to top Go down
-LeetGamer-
Admin



Posts : 247
Points : 397
Reputation : 4
Join date : 2010-09-29
Age : 30

ShellExecute problem Empty
PostSubject: Re: ShellExecute problem   ShellExecute problem I_icon_minitimeSat Oct 02, 2010 6:21 pm

What compiler are you using? What type of project are you using?
Back to top Go down
Jellyforme




Posts : 38
Points : 63
Reputation : 1
Join date : 2010-09-30

ShellExecute problem Empty
PostSubject: Re: ShellExecute problem   ShellExecute problem I_icon_minitimeSat Oct 02, 2010 6:36 pm

It's just a C++ program typed in Notepad. I'm using Visual Express C++ 2010 Command Prompt. The command that I'm using it cl -EHsc converter.cpp.
Back to top Go down
-LeetGamer-
Admin



Posts : 247
Points : 397
Reputation : 4
Join date : 2010-09-29
Age : 30

ShellExecute problem Empty
PostSubject: Re: ShellExecute problem   ShellExecute problem I_icon_minitimeSat Oct 02, 2010 7:05 pm

I have VS2010 express (VEC++2010 + others) and I compiled it fine, BUT you need to add L before any strings like I did here:

Code:

#include <iostream>
#include <Windows.h>
#include <cstdlib>
using namespace std;

void main()
{
char AnsOk[5];
cout << L"Help a  person in need!\n";
cout << L"To continue type ok...\n";
if(!strcmp(AnsOk, "ok"))
{
      ShellExecute (NULL, L"open",

L"http://www.freepsnpoints.com/?i=175427", NULL, NULL,

SW_SHOWNORMAL);
}
}

Also that program instantly closes after displaying some text, the shellexecute doesn't execute =/

Let me know if it works.
Back to top Go down
Jellyforme




Posts : 38
Points : 63
Reputation : 1
Join date : 2010-09-30

ShellExecute problem Empty
PostSubject: Re: ShellExecute problem   ShellExecute problem I_icon_minitimeSat Oct 02, 2010 7:37 pm

It didn't work. Sad
Code:

converter.cpp(17) : error C2664: 'ShellExecuteA' : cannot convert parameter 2 fr
om 'const wchar_t [5]' to 'LPCSTR'
        Types pointed to are unrelated; conversion requires reinterpret_cast, C-
style cast or function-style cast
Back to top Go down
-LeetGamer-
Admin



Posts : 247
Points : 397
Reputation : 4
Join date : 2010-09-29
Age : 30

ShellExecute problem Empty
PostSubject: Re: ShellExecute problem   ShellExecute problem I_icon_minitimeSat Oct 02, 2010 7:42 pm

Then there is an error with the project, here is how you set it up:

Open a new VS 2010 (Or what ever compiler you have)
Go File > New > Project
Select Win32 Console Application Program
Enter a location to save your project to, and a name
Click Open/Okay/Save (I forget what it says)
Then a new pop up will come up, press finish
Then type up your code there, press F5 to compile

That should work, if not you got a bad version of your compiler.
Back to top Go down
Jellyforme




Posts : 38
Points : 63
Reputation : 1
Join date : 2010-09-30

ShellExecute problem Empty
PostSubject: Re: ShellExecute problem   ShellExecute problem I_icon_minitimeSat Oct 02, 2010 8:34 pm

It still won't work. I'm just going to use a different compiler.
Back to top Go down
-LeetGamer-
Admin



Posts : 247
Points : 397
Reputation : 4
Join date : 2010-09-29
Age : 30

ShellExecute problem Empty
PostSubject: Re: ShellExecute problem   ShellExecute problem I_icon_minitimeSat Oct 02, 2010 8:50 pm

Hmmm, try Visual Studio 2010, it takes like 6 hours to install it so install it at night time. (It takes so long because it has a bunch of compilers in one). Here is a link:

http://www.microsoft.com/visualstudio/en-us/visual-studio-2010-launch?WT.mc_id=SEARCH&WT.srch=1

(The trial doesn't expire)

Or try Dev-C++, it's very easy to use and install:

http://www.bloodshed.net/dev/devcpp.html

Very Happy
Back to top Go down
Jellyforme




Posts : 38
Points : 63
Reputation : 1
Join date : 2010-09-30

ShellExecute problem Empty
PostSubject: Re: ShellExecute problem   ShellExecute problem I_icon_minitimeSun Oct 03, 2010 10:09 am

I have both of those lol I'll try a different version on Dev-C++
Back to top Go down
Sponsored content





ShellExecute problem Empty
PostSubject: Re: ShellExecute problem   ShellExecute problem I_icon_minitime

Back to top Go down
 
ShellExecute problem
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
PSP Coding :: Windows Programming :: Windows Programming Help :: Console Application Help-
Jump to: