ShellExecuteW - Help Plz!?
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: ShellExecuteW - Help Plz!?

Hybrid View

  1. #1
    Join Date
    May 2012
    Posts
    26

    Question ShellExecuteW - Help Plz!?

    Hi guys,

    i want to run an .exe file through ShellExecuteW and if there is no .exe file in the path, i would like to return a msg box, but the code
    Code:
    if(ShellExecuteW!=ERROR_SUCCESS)
    is not working and if i report
    Code:
    int run = ShellExecute(Path)
    it says that the "int" is wrong... i barely know about c++, or better, i just know how to interpret basic lines of code..Any Help Plz?!

    Thanks :

    Duarte V.

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    12,108

    Re: ShellExecuteW - Help Plz!?

    The first example isn't how you call a function.

    In the second, ShellExecute returns an HINSTANCE, not an int.

    You really need to have a minimal understanding before trying to write programs. I don't think you have that yet.

  3. #3
    Join Date
    May 2012
    Posts
    26

    Re: ShellExecuteW - Help Plz!?

    im not writing a full program, is just a small .dll module to help me on another program that i manage to code a bit and its visual programming btw, i just would like to know how do i "challenge" ShellExecute into an !=Error_Success return, nothing more but ok, i will search for more things on net since that with 29 years old and no kind of school about this things i cannot find ppl that might help me with a base thing that will trigger the whole process of what im doing into a bit more higher level..i understand that is completely stupid for you to give a base answer to this considering your knowledge, but theres no problem..next time i will spend about 1000€ that i dont have cause im unemployed far 8 yeras on a private school just to know this base thing (cause i will never code hard stuff) in order to put my VSTi for sale in a small price of 5€ each .. no problem... Thanks ...anyway theres no more software that cannot be cracked and since my idea of do not promote piracy runs into a small price for your software cause ppl can afford, and the new based sales for software are through internet wich your browser copy/pastes from the server into the hardisk, its completely natural that todays software enterprises put a lot of money into software to get it once for full, instead of getting it little by little and providing a full confort into pplīs wallets ... well... i guess coders like piracy else they would not promte it with their own software

  4. #4
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    12,108

    Re: ShellExecuteW - Help Plz!?

    If that made any kind of sense at all, I'd try to reply, but unfortunately, it doesn't.

    The first link Google brought up, shows how it's used. At least try to come up with code that follows the documentation.
    http://msdn.microsoft.com/en-us/libr...=vs.85%29.aspx

    Unfortunately some beginners confuse C++ with some kind of scripting language and think all you need is to know how to write a line of code or two and you're done. It doesn't work that way, and getting snippy isn't going to change that.

  5. #5
    Join Date
    May 2012
    Posts
    26

    Re: ShellExecuteW - Help Plz!?

    i dont mind ... im searching for answers now on internet and what ive wrote makes sense to me, i i will not ask for any kind of help here anymore, i see that this is just for experts and that you are not able to give the so called line of code.. this is what im doing:
    Code:
    #include ".\OpenregGui.h"
    
    
    REGISTER_GUI_PLUGIN( OpenregGui, L"My OpenReg E" );
    
    OpenregGui::OpenregGui( IMpUnknown* host ) : MpGuiBase(host)
    {
    	// initialise pins.
    	filename.initialize( this, 0, static_cast<MpGuiBaseMemberPtr>(&OpenregGui::onSetFilename) );
    	trigger.initialize( this, 1, static_cast<MpGuiBaseMemberPtr>(&OpenregGui::onSetTrigger) );
    	HKEY hKey;
    
        int MessageBox(HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType);
    LPCTSTR Caption = TEXT("Running in DEMO MODE!");
    
    INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                       LPSTR lpCmdLine, int nCmdShow);
    {
       MessageBox( NULL,
                    TEXT("WARNING:\n \nIf you did not downloaded this software from WWW.BEATASSIST.EU\n \nDO NOT CLICK ON THE REGISTER BUTTON\n \nIt might been trojened, altered or have some kind of malware!\nMAKE SURE you downloaded it from WWW.BEATASSIST.EU!\n \nThis message will disapear after you register your software!\n \nCurrent Status: DEMO MODE!"),
                    Caption,
                    MB_OK | MB_ICONWARNING);
                    if(msgBox=MB_OK)
     {
    
    wchar_t fullFilename[MAX_PATH];
    
    		getHost()->resolveFilename( filename.getValue().c_str(), MAX_PATH, fullFilename );
    
    HINSTANCE hInstance = ShellExecuteW(0, L"open", fullFilename, L"", L"", SW_NORMAL );
       if (hInstance != ERROR_SUCCESS)
    {
        int del = RegDeleteKey(HKEY_CURRENT_USER, TEXT(""));
    del;
    
    RegCloseKey(hKey);
    }
    
    }
    }
    }
    
    // handle pin updates.
    void OpenregGui::onSetFilename()
    {
    	// filename changed
    }
    
    void OpenregGui::onSetTrigger()
    {
        if( trigger == false && previousTrigger == true )
    {
    
    	 wchar_t fullFilename[MAX_PATH];
    
    		getHost()->resolveFilename( filename.getValue().c_str(), MAX_PATH, fullFilename );
    
            ShellExecuteW(0, L"open", fullFilename, L"", L"", SW_NORMAL );
    
    }
    previousTrigger = trigger;
    
    }
    most of this line wehre found out through my own research...dont worry i will manage myself and btw, i dont know what coders like anyway i know that good software at a good price works better than good software at an expensive price ... most of ppl do not code for NASA and they turn the prices very high although not so much lately

  6. #6
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Posts
    12,108

    Re: ShellExecuteW - Help Plz!?

    That code doesn't look anything like your original post. So what does ShellExecute return?

  7. #7
    Join Date
    May 2012
    Posts
    26

    Re: ShellExecuteW - Help Plz!?

    well, im doing it better now, i was launching ShellExecute under the OpenregGui::OpenregGui( IMpUnknown* host ) : MpGuiBase(host) and it always gave me error when introducing the module into the visual programming method, im now using it under the void OpenregGui:nSetTrigger() method and is working fine despite of having to click on a button for it to work and i would like it to run automatically when the module expands on the program, basicaly when it opens.. this is a .dll module that works inside of another software and when the software opens this .dll runs (as you may know) thats why i would like to insert it when it initializes and not by clicking on a control Thanks

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center