-
January 23rd, 2009, 06:15 PM
#1
Build Errors
Hi,
I am trying to launch a program from a button and when I introduced the ShellExecuteEx code, I began to have a bunch of problems. I've since resolved all of them but one.
Here is the code:
Code:
130. private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
131.
132. {
133. SHELLEXECUTEINFO ExecuteInfo;
134.
135. memset(&ExecuteInfo, 0, sizeof(ExecuteInfo));
136.
137. ExecuteInfo.cbSize = sizeof(ExecuteInfo);
138. ExecuteInfo.fMask = 0;
139. ExecuteInfo.hwnd = 0;
140. ExecuteInfo.lpVerb = _T("open"); // Operation to perform
141. ExecuteInfo.lpFile = _T("c:\\windows\\notepad.exe"); // Application name
142. ExecuteInfo.lpParameters = 0; // Additional parameters
143. ExecuteInfo.lpDirectory = 0; // Default directory
144. ExecuteInfo.nShow = SW_SHOW;
145. ExecuteInfo.hInstApp = 0;
146.
147. if(ShellExecuteEx(&ExecuteInfo) == FALSE)
148. // Could not start application -> call 'GetLastError()'
149. }
150. };
151. }
And here is my error:
(149) : error C2143: syntax error : missing ';' before '}'
It looks like the error is on line 149. Google couldn't help me solve my problem this time.
What I'm confused about, is that line 149 is a single closing bracket.
I can't seem to figure out what I need to do, so any help would be grateful
Thanks
-
January 23rd, 2009, 06:26 PM
#2
Re: Build Errors
Your if(ShellExecuteEx(&ExecuteInfo) == FALSE) lack a { but have a closing }
That ); will probaly cause some trouble as well
Last edited by S_M_A; January 23rd, 2009 at 06:28 PM.
-
January 23rd, 2009, 06:46 PM
#3
Re: Build Errors
I thought that the opening and closing brackets at lines 132 and 149 applied for
Code:
if(ShellExecuteEx(&ExecuteInfo) == FALSE)
I got 2 more errors when I added the opening bracket
Code:
{
if(ShellExecuteEx(&ExecuteInfo) == FALSE)
// Could not start application -> call 'GetLastError()'
}
Errors:
(6) : error C2143: syntax error : missing ';' before 'using'
(150) : error C2143: syntax error : missing ';' before '}'
19) : fatal error C1075: end of file found before the left brace '{'
So then I added another closing bracket on line 146 so it too had a closing bracket
Code:
{
SHELLEXECUTEINFO ExecuteInfo;
memset(&ExecuteInfo, 0, sizeof(ExecuteInfo));
ExecuteInfo.cbSize = sizeof(ExecuteInfo);
ExecuteInfo.fMask = 0;
ExecuteInfo.hwnd = 0;
ExecuteInfo.lpVerb = _T("open"); // Operation to perform
ExecuteInfo.lpFile = _T("c:\\windows\\notepad.exe"); // Application name
ExecuteInfo.lpParameters = 0; // Additional parameters
ExecuteInfo.lpDirectory = 0; // Default directory
ExecuteInfo.nShow = SW_SHOW;
ExecuteInfo.hInstApp = 0;
}
It then went down to two errors:
(147) : error C2059: syntax error : '{'
(147) : error C2334: unexpected token(s) preceding '{'; skipping apparent function body
-
January 23rd, 2009, 07:04 PM
#4
Re: Build Errors
Originally Posted by weirddemon
Here is the code:
Code:
130. private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
Wrong forum. As far as this forum is concerned, that "^" is the exclusive-or operator in C++, and that line of code makes no sense whatsoever.
That code is managed C++, and this is not a managed C++ forum. This forum is explicitly for non-managed, traditional C++ using Visual C++ using MFC, ATL, COM, etc.
Regards,
Paul McKenzie
-
January 24th, 2009, 03:42 PM
#5
Re: Build Errors
So, then do I wait for a Mod to take it over to the other section, or open up a new thread there?
-
January 24th, 2009, 05:58 PM
#6
Re: Build Errors
Originally Posted by weirddemon
So, then do I wait for a Mod to take it over to the other section, or open up a new thread there?
Usually the moderators pick up the thread and move it to the appropriate forum. If it isn't moved, then maybe you can alert one of them to the thread to have it moved.
Regards,
Paul McKenzie
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|