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. CreateFile problem

CreateFile problem

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestionsysadmin
4 Posts 3 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.
  • B Offline
    B Offline
    birajendu
    wrote on last edited by
    #1

    Hi I am using the following createfile function to open a file in network share. HANDLE file = CreateFile( File, GENERIC_READ , FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 ); When the file name is \\10.195.1.54\Temp\expample.ini file it is giving error 5. But when i input the network share name instead of ip like \\Extream\Temp\expample.ini it is opening. can you please help me what is the problem i am having?

    Birajendu SonicWALL Bangalore India

    A D 2 Replies Last reply
    0
    • B birajendu

      Hi I am using the following createfile function to open a file in network share. HANDLE file = CreateFile( File, GENERIC_READ , FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 ); When the file name is \\10.195.1.54\Temp\expample.ini file it is giving error 5. But when i input the network share name instead of ip like \\Extream\Temp\expample.ini it is opening. can you please help me what is the problem i am having?

      Birajendu SonicWALL Bangalore India

      A Offline
      A Offline
      Ahmed Charfeddine
      wrote on last edited by
      #2

      the system GetLastError API often can tell you about error details especially when you also try to retrieve the rror code and tranlate it into readable text. Use the following snippget of code and tell us what is the message you receive. That case you may be even be able to understand the pbm yourself.

      std::string GetFormattedSystemError()
      {
      LPVOID lpMsgBuf;
      LPVOID lpDisplayBuf;
      DWORD dw = GetLastError();

      FormatMessageA(
      	FORMAT\_MESSAGE\_ALLOCATE\_BUFFER | 
      	FORMAT\_MESSAGE\_FROM\_SYSTEM |
      	FORMAT\_MESSAGE\_IGNORE\_INSERTS,
      	NULL,
      	dw,
      	MAKELANGID(LANG\_NEUTRAL, SUBLANG\_DEFAULT),
      	(LPTSTR) &lpMsgBuf,
      	0, NULL );
      
      
      char\* pMessage = (char\*) lpMsgBuf;
      return std::string(pMessage);
      

      }

      Good luck.

      Easy Profiler : a compile-time profiler for C++ www.potatosoftware.com

      1 Reply Last reply
      0
      • B birajendu

        Hi I am using the following createfile function to open a file in network share. HANDLE file = CreateFile( File, GENERIC_READ , FILE_SHARE_READ, 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0 ); When the file name is \\10.195.1.54\Temp\expample.ini file it is giving error 5. But when i input the network share name instead of ip like \\Extream\Temp\expample.ini it is opening. can you please help me what is the problem i am having?

        Birajendu SonicWALL Bangalore India

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

        birajendu wrote:

        When the file name is \\10.195.1.54\Temp\expample.ini file it is giving error 5.

        Which equates to ERROR_ACCESS_DENIED. Are you sure that the Extream server has an IP address of 10.195.1.54?

        "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

        B 1 Reply Last reply
        0
        • D David Crow

          birajendu wrote:

          When the file name is \\10.195.1.54\Temp\expample.ini file it is giving error 5.

          Which equates to ERROR_ACCESS_DENIED. Are you sure that the Extream server has an IP address of 10.195.1.54?

          "Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          B Offline
          B Offline
          birajendu
          wrote on last edited by
          #4

          Yes i am sure about that.cause i can open that loaction through exploler using \\10.195.1.54\temp. it is not about the perticular extreme server in my Corporate lan. This happens with all PC prsent in Lan, If i try thru the name of the system than it works fine , but though IP it does not work.... :) No idea why? I gave a another try.I connected two PC to a router. So here i got IP from router.There is no scenario of DNS here, so i tried trough IP only(some thing like \\192.168.1.2\temp\emaple.ini) and worked perfactly. SO i am confused where is the problem?

          Birajendu SonicWALL Bangalore India

          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