CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6

Thread: Build Errors

  1. #1
    Join Date
    Jan 2009
    Posts
    9

    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

  2. #2
    Join Date
    Oct 2006
    Location
    Sweden
    Posts
    3,654

    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.
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible, you are, by
    definition, not smart enough to debug it.
    - Brian W. Kernighan

    To enhance your chance's of getting an answer be sure to read
    http://www.codeguru.com/forum/announ...nouncementid=6
    and http://www.codeguru.com/forum/showthread.php?t=366302 before posting

    Refresh your memory on formatting tags here
    http://www.codeguru.com/forum/misc.php?do=bbcode

    Get your free MS compiler here
    https://visualstudio.microsoft.com/vs

  3. #3
    Join Date
    Jan 2009
    Posts
    9

    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

  4. #4
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Build Errors

    Quote Originally Posted by weirddemon View Post
    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

  5. #5
    Join Date
    Jan 2009
    Posts
    9

    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?

  6. #6
    Join Date
    Apr 1999
    Posts
    27,449

    Re: Build Errors

    Quote Originally Posted by weirddemon View Post
    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
  •  





Click Here to Expand Forum to Full Width

Featured