6 Replies - 4240 Views - Last Post: 27 April 2009 - 09:05 AM Rate Topic: -----

#1 purpleCRAYON  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 24-April 09

'handle' : undeclared identifier | Need help with ShellExecute

Post icon  Posted 24 April 2009 - 10:37 PM

Hello, I keep getting these errors / warnings:
1>c:\users\dan\documents\visual studio 2008\projects\plaunchv1\plaunchv1\main.cpp(29) : error C2065: 'handle' : undeclared identifier
1>c:\users\dan\documents\visual studio 2008\projects\plaunchv1\plaunchv1\main.cpp(29) : warning C4129: 'P' : unrecognized character escape sequence
1>c:\users\dan\documents\visual studio 2008\projects\plaunchv1\plaunchv1\main.cpp(29) : warning C4129: 'D' : unrecognized character escape sequence
1>c:\users\dan\documents\visual studio 2008\projects\plaunchv1\plaunchv1\main.cpp(29) : warning C4129: 'D' : unrecognized character escape sequence
1>c:\users\dan\documents\visual studio 2008\projects\plaunchv1\plaunchv1\main.cpp(29) : warning C4129: 'D' : unrecognized character escape sequence
1>Build log was saved at "file://c:\Users\Dan\Documents\Visual Studio 2008\Projects\PLaunchV1\PLaunchV1\Debug\BuildLog.htm"
1>PLaunchV1 - 1 error(s), 4 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========




This is my sourcode:
#include <iostream>
#include <windows.h>
#include <tlhelp32.h>
#include <stdio.h>
#include <shlwapi.h>
#include <process.h>
#pragma comment(lib, "th32.lib")

using namespace std;

void main()
{
  cout << "Starting Program " << endl; 
  Sleep(1000);
  cout << "5" << endl;
  Sleep(1000);
  cout << "4" << endl;
  Sleep(1000);
  cout << "3" << endl;
  Sleep(1000);
  cout << "2" << endl;
  Sleep(1000);
  cout << "1" << endl;
  Sleep(1000);
  cout << "Program is starting." << endl;
  Sleep(500);
  cout << "Program is starting.." << endl;
  Sleep(2000);
  ShellExecute(handle, NULL, "C:\Program Files\File\File\lol.exe", NULL, NULL, SW_SHOWNORMAL);
}

 


I am using Microsoft Visual C++ 2008 Express Edition. I turned off unicode etc, to reduce bugs, and the reason I put all those #includes was to try and identify "handle".

Any ideas?

;)

Is This A Good Question/Topic? 0
  • +

Replies To: 'handle' : undeclared identifier | Need help with ShellExecute

#2 chris772  Icon User is offline

  • D.I.C Head

Reputation: 5
  • View blog
  • Posts: 190
  • Joined: 13-March 09

Re: 'handle' : undeclared identifier | Need help with ShellExecute

Posted 24 April 2009 - 10:47 PM

It may be a syntax issue, because I don't think "handle" is a valid variable type. Try using "HINSTANCE".
Was This Post Helpful? 0
  • +
  • -

#3 purpleCRAYON  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 24-April 09

Re: 'handle' : undeclared identifier | Need help with ShellExecute

Posted 24 April 2009 - 11:00 PM

I already fixed it, thanks. :)
Was This Post Helpful? 0
  • +
  • -

#4 janotte  Icon User is offline

  • code > sword
  • member icon

Reputation: 990
  • View blog
  • Posts: 5,141
  • Joined: 28-September 06

Re: 'handle' : undeclared identifier | Need help with ShellExecute

Posted 24 April 2009 - 11:02 PM

Where are you declaring "handle"?

What 'type of thing' is it?

if I write
int x;
The compiler knows that the type of thing 'x' is is 'int'.
Was This Post Helpful? 0
  • +
  • -

#5 purpleCRAYON  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 13
  • Joined: 24-April 09

Re: 'handle' : undeclared identifier | Need help with ShellExecute

Posted 24 April 2009 - 11:27 PM

View Postjanotte, on 24 Apr, 2009 - 10:02 PM, said:

Where are you declaring "handle"?

What 'type of thing' is it?

if I write
int x;
The compiler knows that the type of thing 'x' is is 'int'.


I'm not sure what the handle was, it was a direct copy + paste from msdn with my directory added. Now I use this:

  ShellExecute(NULL, "open", GetFullDirectory("\\lol.exe"), NULL, NULL, SW_SHOWNORMAL);

Was This Post Helpful? 0
  • +
  • -

#6 pepsi_gx  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 27-April 09

Re: 'handle' : undeclared identifier | Need help with ShellExecute

Posted 27 April 2009 - 05:42 AM

View PostpurpleCRAYON, on 24 Apr, 2009 - 10:27 PM, said:

View Postjanotte, on 24 Apr, 2009 - 10:02 PM, said:

Where are you declaring "handle"?

What 'type of thing' is it?

if I write
int x;
The compiler knows that the type of thing 'x' is is 'int'.


I'm not sure what the handle was, it was a direct copy + paste from msdn with my directory added. Now I use this:

  ShellExecute(NULL, "open", GetFullDirectory("\\lol.exe"), NULL, NULL, SW_SHOWNORMAL);

Hello all,

I got such a failure notice:
error C2664: 'ShellExecuteW' : cannot convert parameter 2 from 'const char [5]' to 'LPCWSTR'


any idea?
Was This Post Helpful? 0
  • +
  • -

#7 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6063
  • View blog
  • Posts: 23,515
  • Joined: 23-August 08

Re: 'handle' : undeclared identifier | Need help with ShellExecute

Posted 27 April 2009 - 09:05 AM

If you're compiling with UNICODE enabled (as it appears you are), you must prefix your constant character strings with L to use wide-character strings:
ShellExecute(NULL, L"open", GetFullDirectory(L"\\lol.exe"),NULL, NULL, SW_SHOWNORMAL);

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1