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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Executing Remote Commands on an FTP Server

Executing Remote Commands on an FTP Server

Scheduled Pinned Locked Moved C / C++ / MFC
sysadminquestion
12 Posts 2 Posters 1 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.
  • A Alexinuk

    Hi, I am trying to find a way of executing remote commands on an FTP server programmatically (i.e. some way of getting the same functionality as the ftp command 'quote'). CFtpConnection and the related classes don't have this functionality, so does anyone have any idea where I should look? are there some SDK commands I can use? Thanks in advance, Alex

    A Offline
    A Offline
    AlexO
    wrote on last edited by
    #2

    MFC: CFtpConnection::Command SDK: ::FtpCommand

    A 1 Reply Last reply
    0
    • A AlexO

      MFC: CFtpConnection::Command SDK: ::FtpCommand

      A Offline
      A Offline
      Alexinuk
      wrote on last edited by
      #3

      Which version of MFC is this? I can't find a reference on MSDN either - I'm using VC 6.0...?

      A 1 Reply Last reply
      0
      • A Alexinuk

        Which version of MFC is this? I can't find a reference on MSDN either - I'm using VC 6.0...?

        A Offline
        A Offline
        AlexO
        wrote on last edited by
        #4

        VC7. For VC6 use ::FtpCommand in wininet.dll(.lib)

        A 1 Reply Last reply
        0
        • A AlexO

          VC7. For VC6 use ::FtpCommand in wininet.dll(.lib)

          A Offline
          A Offline
          Alexinuk
          wrote on last edited by
          #5

          AlexO wrote: VC7. For VC6 use ::FtpCommand in wininet.dll(.lib) Do you mean link with this? could you explain a bit more? Thanks, Alex

          A 1 Reply Last reply
          0
          • A Alexinuk

            AlexO wrote: VC7. For VC6 use ::FtpCommand in wininet.dll(.lib) Do you mean link with this? could you explain a bit more? Thanks, Alex

            A Offline
            A Offline
            AlexO
            wrote on last edited by
            #6

            bool MyClass::ExecuteCommand(const CFtpConnection& rMyValidFtpconnection) { return TRUE == ::FtpCommand(rMyValidFtpconnection, FALSE, FTP_TRANSFER_TYPE_BINARY, _T("not_supported_by_mfc_ftp_command"), 12345, 0); } CInternetFile* MyClass::ExecuteCommandWithReturn(CFtpConnection& rMyValidFtpconnection) { HINTERNET hSteram = 0; if(::FtpCommand(rMyValidFtpconnection, TRUE, FTP_TRANSFER_TYPE_BINARY,_T("not_supported_by_mfc_ftp_command_that_returns data"), 123456, &hSteram)) { return new CInternetFile(hSteram , T("not_supported_by_mfc_ftp_command_that_returns data"), &rMyValidFtpconnection, TRUE); } return 0; }

            A 1 Reply Last reply
            0
            • A AlexO

              bool MyClass::ExecuteCommand(const CFtpConnection& rMyValidFtpconnection) { return TRUE == ::FtpCommand(rMyValidFtpconnection, FALSE, FTP_TRANSFER_TYPE_BINARY, _T("not_supported_by_mfc_ftp_command"), 12345, 0); } CInternetFile* MyClass::ExecuteCommandWithReturn(CFtpConnection& rMyValidFtpconnection) { HINTERNET hSteram = 0; if(::FtpCommand(rMyValidFtpconnection, TRUE, FTP_TRANSFER_TYPE_BINARY,_T("not_supported_by_mfc_ftp_command_that_returns data"), 123456, &hSteram)) { return new CInternetFile(hSteram , T("not_supported_by_mfc_ftp_command_that_returns data"), &rMyValidFtpconnection, TRUE); } return 0; }

              A Offline
              A Offline
              Alexinuk
              wrote on last edited by
              #7

              Cheers for the reply. I understand how to use the function, but I simply can't use it. I get the message: c:\ftpcmd\ftpcmd.cpp(32) : error C2065: 'FtpCommand' : undeclared identifier or that 'FtpCommand is not a part of Global Namespace'. I've tried linking with wininet.lib, and i'm on IE6.0. How can I use this function? -Alex

              A 1 Reply Last reply
              0
              • A Alexinuk

                Cheers for the reply. I understand how to use the function, but I simply can't use it. I get the message: c:\ftpcmd\ftpcmd.cpp(32) : error C2065: 'FtpCommand' : undeclared identifier or that 'FtpCommand is not a part of Global Namespace'. I've tried linking with wininet.lib, and i'm on IE6.0. How can I use this function? -Alex

                A Offline
                A Offline
                AlexO
                wrote on last edited by
                #8

                This brings me to the original point. When you look through MSDN for description of the function at the bottom of the page you see the following table: Stock Implementation wininet.dll Custom Implementation No Header Wininet.h Import library Wininet.lib Minimum availability Internet Explorer 5 Minimum operating systems Windows NT 4.0, Windows 95, Windows CE 2.12 Which implies that you have to link to Wininet.lib(you got that), AND you have to include Wininet.h (you did not get that).

                A 1 Reply Last reply
                0
                • A AlexO

                  This brings me to the original point. When you look through MSDN for description of the function at the bottom of the page you see the following table: Stock Implementation wininet.dll Custom Implementation No Header Wininet.h Import library Wininet.lib Minimum availability Internet Explorer 5 Minimum operating systems Windows NT 4.0, Windows 95, Windows CE 2.12 Which implies that you have to link to Wininet.lib(you got that), AND you have to include Wininet.h (you did not get that).

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

                  Just in case you forgot, in begining of stdafx.h you should have something like #define _WIN32_IE 0x0500 //_WIN32_IE>=0x0500

                  A 1 Reply Last reply
                  0
                  • A AlexO

                    Just in case you forgot, in begining of stdafx.h you should have something like #define _WIN32_IE 0x0500 //_WIN32_IE>=0x0500

                    A Offline
                    A Offline
                    Alexinuk
                    wrote on last edited by
                    #10

                    Right, done all that. I've linked with wininet.lib, #include'd wininet.h, and added the line you suggested to stdafx.h. no joy, however - I still get the same error messages. I've looked through wininet.h and can't find the prototype for FtpCommand() which makes me think i might need an update...? Although MSDN (on the web - not my copy) mentions that this function should be available from Win95 up. I'm using Win98 SE. Any ideas? btw: really appreciate the help! -Alex

                    A 1 Reply Last reply
                    0
                    • A Alexinuk

                      Right, done all that. I've linked with wininet.lib, #include'd wininet.h, and added the line you suggested to stdafx.h. no joy, however - I still get the same error messages. I've looked through wininet.h and can't find the prototype for FtpCommand() which makes me think i might need an update...? Although MSDN (on the web - not my copy) mentions that this function should be available from Win95 up. I'm using Win98 SE. Any ideas? btw: really appreciate the help! -Alex

                      A Offline
                      A Offline
                      AlexO
                      wrote on last edited by
                      #11

                      I do not have VC6 at hand, but I suspect you need to download/install Platform SDK, where the Wininet.h is up to date. it is free but you have to search msdn.microsoft.com for it.

                      A 1 Reply Last reply
                      0
                      • A AlexO

                        I do not have VC6 at hand, but I suspect you need to download/install Platform SDK, where the Wininet.h is up to date. it is free but you have to search msdn.microsoft.com for it.

                        A Offline
                        A Offline
                        Alexinuk
                        wrote on last edited by
                        #12

                        Cheers mate. That sorted it. It's amazing how hard it is to come across anything that makes you think that this could be the problem. Thanks again, Alex

                        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