Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. ShellExecute and File Properties

ShellExecute and File Properties

Scheduled Pinned Locked Moved C / C++ / MFC
comlinuxtestingbeta-testingquestion
12 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Lost User

    I'm trying to use ShellExecute to display the properties of file, like in explorer. I'm using something like this, ShellExecute(NULL,"PROPERTIES","c:\\winnt\\notepad.exe",NULL,NULL,SW_NORMAL); but it always returns code 31, which is invalid verb ("PROPERTIES"). I checked on MSDN, and the verb is correct, and it doesn't seem to be obsolete (I'm testing on a 2000 machine). Any suggestions on what I'm doing wrong? Thanks, Aaron Stubbendieck

    P Offline
    P Offline
    Prakash Nadar
    wrote on last edited by
    #2

    try "properties" in lower case and also try using ShellExecuteEx if possiable.


    This space is empty.

    L 1 Reply Last reply
    0
    • L Lost User

      I'm trying to use ShellExecute to display the properties of file, like in explorer. I'm using something like this, ShellExecute(NULL,"PROPERTIES","c:\\winnt\\notepad.exe",NULL,NULL,SW_NORMAL); but it always returns code 31, which is invalid verb ("PROPERTIES"). I checked on MSDN, and the verb is correct, and it doesn't seem to be obsolete (I'm testing on a 2000 machine). Any suggestions on what I'm doing wrong? Thanks, Aaron Stubbendieck

      N Offline
      N Offline
      Neha
      wrote on last edited by
      #3

      Even I have the same problem. I am getting the error as ERROR_NO_ASSOCIATION.

      P 1 Reply Last reply
      0
      • N Neha

        Even I have the same problem. I am getting the error as ERROR_NO_ASSOCIATION.

        P Offline
        P Offline
        Prakash Nadar
        wrote on last edited by
        #4

        From your reply i did some R&D on this, for some reason "properties" verb does not work with ShellExecute(...) but works with ShellExecuteEx(...)


        This space is empty.

        N 1 Reply Last reply
        0
        • L Lost User

          I'm trying to use ShellExecute to display the properties of file, like in explorer. I'm using something like this, ShellExecute(NULL,"PROPERTIES","c:\\winnt\\notepad.exe",NULL,NULL,SW_NORMAL); but it always returns code 31, which is invalid verb ("PROPERTIES"). I checked on MSDN, and the verb is correct, and it doesn't seem to be obsolete (I'm testing on a 2000 machine). Any suggestions on what I'm doing wrong? Thanks, Aaron Stubbendieck

          B Offline
          B Offline
          BaldwinMartin
          wrote on last edited by
          #5

          Try this SHELLEXECUTEINFO sei; ZeroMemory(&sei, sizeof(SHELLEXECUTEINFO)); sei.cbSize = sizeof (SHELLEXECUTEINFO); sei.lpVerb = NULL; sei.lpFile = m_strexefilename; sei.nShow = SW_SHOW; sei.hInstApp = NULL; sei.lpDirectory = NULL; sei.fMask = SEE_MASK_DOENVSUBST|SEE_MASK_NOCLOSEPROCESS; sei.lpParameters = NULL; if (ShellExecuteEx (&sei) ) return TRUE; else return FALSE; Now start a thread and monitor it, monitor sei Best Wishes, ez_way

          L 1 Reply Last reply
          0
          • B BaldwinMartin

            Try this SHELLEXECUTEINFO sei; ZeroMemory(&sei, sizeof(SHELLEXECUTEINFO)); sei.cbSize = sizeof (SHELLEXECUTEINFO); sei.lpVerb = NULL; sei.lpFile = m_strexefilename; sei.nShow = SW_SHOW; sei.hInstApp = NULL; sei.lpDirectory = NULL; sei.fMask = SEE_MASK_DOENVSUBST|SEE_MASK_NOCLOSEPROCESS; sei.lpParameters = NULL; if (ShellExecuteEx (&sei) ) return TRUE; else return FALSE; Now start a thread and monitor it, monitor sei Best Wishes, ez_way

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #6

            I tried your code with the only change being changing m_strexefilename to a static path for a file. That will open the file just fine, as will setting the verb to "OPEN" or "open". However, if I try setting it to "properties" a message box appears that says:

            "This file does not have a program associated with it for performing this action. Create an association in the Folder Options control panel."

            Any idea what I could be doing wrong? Thanks, Aaron Stubbendieck

            L A B 3 Replies Last reply
            0
            • P Prakash Nadar

              try "properties" in lower case and also try using ShellExecuteEx if possiable.


              This space is empty.

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #7

              That doesn't appear to make a difference for any of the verbs. Aaron Stubbendieck

              1 Reply Last reply
              0
              • L Lost User

                I tried your code with the only change being changing m_strexefilename to a static path for a file. That will open the file just fine, as will setting the verb to "OPEN" or "open". However, if I try setting it to "properties" a message box appears that says:

                "This file does not have a program associated with it for performing this action. Create an association in the Folder Options control panel."

                Any idea what I could be doing wrong? Thanks, Aaron Stubbendieck

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #8

                Also, for any verb, explore, find, etc also give the same visual error.

                1 Reply Last reply
                0
                • L Lost User

                  I tried your code with the only change being changing m_strexefilename to a static path for a file. That will open the file just fine, as will setting the verb to "OPEN" or "open". However, if I try setting it to "properties" a message box appears that says:

                  "This file does not have a program associated with it for performing this action. Create an association in the Folder Options control panel."

                  Any idea what I could be doing wrong? Thanks, Aaron Stubbendieck

                  A Offline
                  A Offline
                  Anonymous
                  wrote on last edited by
                  #9

                  SHELLEXECUTEINFO typedef struct _SHELLEXECUTEINFO{ DWORD cbSize; ULONG fMask; HWND hwnd; LPCTSTR lpVerb; LPCTSTR lpFile; LPCTSTR lpParameters; LPCTSTR lpDirectory; int nShow; HINSTANCE hInstApp; // Optional members LPVOID lpIDList; LPCSTR lpClass; HKEY hkeyClass; DWORD dwHotKey; HANDLE hIcon; HANDLE hProcess; } SHELLEXECUTEINFO, FAR *LPSHELLEXECUTEINFO; Contains information used by the ShellExecuteEx function. cbSize Size of the structure, in bytes. fMask Array of flags that indicate the content and validity of the other structure members. This can be a combination of the following values: SEE_MASK_CLASSKEY Use the class key given by the hkeyClass member. SEE_MASK_CLASSNAME Use the class name given by the lpClass member. SEE_MASK_CONNECTNETDRV Validate the share and connect to a drive letter. The lpFile member is a Universal Naming Convention (UNC) path of a file on a network. SEE_MASK_DOENVSUBST Expand any environment variables specified in the string given by the lpDirectory or lpFile member. SEE_MASK_FLAG_DDEWAIT Wait for the DDE conversation to terminate before returning (if the ShellExecuteEx function causes a DDE conversation to start). SEE_MASK_FLAG_NO_UI Do not display an error message box if an error occurs. SEE_MASK_HOTKEY Use the hot key given by the dwHotKey member. SEE_MASK_ICON Use the icon given by the hIcon member. SEE_MASK_IDLIST Use the item identifier list given by the lpIDList member. SEE_MASK_INVOKEIDLIST Use the item identifier list given by the lpIDList member to invoke an application. If this member is NULL, the function creates an item identifier list and invokes the application. This flag overrides the SEE_MASK_IDLIST flag. SEE_MASK_NOCLOSEPROCESS Leave the process running after the ShellExecuteEx function exits. The hProcess member receives the handle to the process. hwnd Window handle to any message boxes that the system may produce while executing this function. lpVerb Address of a string specifying the name of a verb. The verb specifies an action for the application to perform. This member defaults to Open if no verb is specified. lpFile Address of a null-terminated string that specifies the name of the file to open or print. The function can open an executable file or a document file, but it can only print a document file. If the path is not included with the name, the current directory is assumed. lpParameters

                  1 Reply Last reply
                  0
                  • L Lost User

                    I tried your code with the only change being changing m_strexefilename to a static path for a file. That will open the file just fine, as will setting the verb to "OPEN" or "open". However, if I try setting it to "properties" a message box appears that says:

                    "This file does not have a program associated with it for performing this action. Create an association in the Folder Options control panel."

                    Any idea what I could be doing wrong? Thanks, Aaron Stubbendieck

                    B Offline
                    B Offline
                    BaldwinMartin
                    wrote on last edited by
                    #10

                    ShellExecute(this->m_hWnd,"open","calc.exe","","", SW_SHOW ); ShellExecute(this->m_hWnd,"open","notepad.exe", "c:\\MyLog.log","",SW_SHOW ); Best Wishes, ez_way

                    L 1 Reply Last reply
                    0
                    • P Prakash Nadar

                      From your reply i did some R&D on this, for some reason "properties" verb does not work with ShellExecute(...) but works with ShellExecuteEx(...)


                      This space is empty.

                      N Offline
                      N Offline
                      Neha
                      wrote on last edited by
                      #11

                      Thanks for the info...

                      1 Reply Last reply
                      0
                      • B BaldwinMartin

                        ShellExecute(this->m_hWnd,"open","calc.exe","","", SW_SHOW ); ShellExecute(this->m_hWnd,"open","notepad.exe", "c:\\MyLog.log","",SW_SHOW ); Best Wishes, ez_way

                        L Offline
                        L Offline
                        Lost User
                        wrote on last edited by
                        #12

                        Those work perfectly, but I'm not sure how that helps me to display the file properties. Thanks

                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • World
                        • Users
                        • Groups