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. Window Service Parameters from INI file

Window Service Parameters from INI file

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
7 Posts 2 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.
  • A Offline
    A Offline
    aman2006
    wrote on last edited by
    #1

    hi I wrote a service in which i want to pass some parameters from INI file but when i give the path as .\\TibcoTCPServer.ini it does not work but if i hard code the path it works fine. Can any body help me how can i pass the ini file path so that service will pick the parameters. Thanks Shailesh

    D 1 Reply Last reply
    0
    • A aman2006

      hi I wrote a service in which i want to pass some parameters from INI file but when i give the path as .\\TibcoTCPServer.ini it does not work but if i hard code the path it works fine. Can any body help me how can i pass the ini file path so that service will pick the parameters. Thanks Shailesh

      D Offline
      D Offline
      David Crow
      wrote on last edited by
      #2

      .\\TibcoTCPServer.ini is a relative path, which means it's relative to whatever happens to be the current working directory at the moment. Use GetModuleFileName(NULL, ...) instead to get the application's fully-qualified path, then replace the filename with TibcoTCPServer.ini.


      "When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen

      A 1 Reply Last reply
      0
      • D David Crow

        .\\TibcoTCPServer.ini is a relative path, which means it's relative to whatever happens to be the current working directory at the moment. Use GetModuleFileName(NULL, ...) instead to get the application's fully-qualified path, then replace the filename with TibcoTCPServer.ini.


        "When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen

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

        if i use GetModuleFinename(NULL..) I Get the Memory could not be read error. My Code is as BOOL FillParams() { CFileFind fileFinder; CIniReader m_IniFile; TCHAR Buffer[BUFSIZE]; DWORD dwRet,nSize; CString error; dwRet = GetModuleFileName(NULL,Buffer,nSize); if( dwRet == 0 ) { error.Format("Failed GetCurrentDirectory %d",GetLastError()); WriteToLog((LPSTR)(LPCTSTR)error); return 0; } WriteToLog(Buffer); // Here i am changing the path.. } But It is failing at GetModuleFineName function or crashing. Any Suggestion.. Thanks Shailesh

        D 1 Reply Last reply
        0
        • A aman2006

          if i use GetModuleFinename(NULL..) I Get the Memory could not be read error. My Code is as BOOL FillParams() { CFileFind fileFinder; CIniReader m_IniFile; TCHAR Buffer[BUFSIZE]; DWORD dwRet,nSize; CString error; dwRet = GetModuleFileName(NULL,Buffer,nSize); if( dwRet == 0 ) { error.Format("Failed GetCurrentDirectory %d",GetLastError()); WriteToLog((LPSTR)(LPCTSTR)error); return 0; } WriteToLog(Buffer); // Here i am changing the path.. } But It is failing at GetModuleFineName function or crashing. Any Suggestion.. Thanks Shailesh

          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          You've failed to inform the function of the size of the buffer.


          "When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen

          A 1 Reply Last reply
          0
          • D David Crow

            You've failed to inform the function of the size of the buffer.


            "When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen

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

            I am using #define BUFSIZE MAX_PATH

            D 1 Reply Last reply
            0
            • A aman2006

              I am using #define BUFSIZE MAX_PATH

              D Offline
              D Offline
              David Crow
              wrote on last edited by
              #6

              I did not indicate that the buffer itself was not large enough. Check your code again. Note the third parameter being passed to GetModuleFileName().


              "When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen

              A 1 Reply Last reply
              0
              • D David Crow

                I did not indicate that the buffer itself was not large enough. Check your code again. Note the third parameter being passed to GetModuleFileName().


                "When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen

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

                Thanks David U are Rock. Thanks shailesh

                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