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. WriteFile vs. _lwrite

WriteFile vs. _lwrite

Scheduled Pinned Locked Moved C / C++ / MFC
helpvisual-studioquestion
8 Posts 5 Posters 2 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.
  • R Offline
    R Offline
    r i s h a b h s
    wrote on last edited by
    #1

    Dear All, My application converts images of TIFF format to TIFFG3Fax. For this i'm using WriteFile sdk method to write data to the file. It fails. But when i use _lwrite, it works fine. Can someone tell me what is the differences between these two functions. _lwrite is obsolete so MSDN says that WriteFile should be used. But it fails with error code 183 (ERROR_ALREADY_EXISTS) Please help! Devoirs, ____________________________________________________________ rishabhs I think therefore I am.

    T B 2 Replies Last reply
    0
    • R r i s h a b h s

      Dear All, My application converts images of TIFF format to TIFFG3Fax. For this i'm using WriteFile sdk method to write data to the file. It fails. But when i use _lwrite, it works fine. Can someone tell me what is the differences between these two functions. _lwrite is obsolete so MSDN says that WriteFile should be used. But it fails with error code 183 (ERROR_ALREADY_EXISTS) Please help! Devoirs, ____________________________________________________________ rishabhs I think therefore I am.

      T Offline
      T Offline
      Toby Opferman
      wrote on last edited by
      #2

      0:000> u kernel32!_lwrite
      kernel32!_lwrite:
      7c838d93 8bff mov edi,edi
      7c838d95 55 push ebp
      7c838d96 8bec mov ebp,esp
      7c838d98 837d1000 cmp dword ptr [ebp+0x10],0x0
      7c838d9c 741f jz kernel32!_lwrite+0x21 (7c838dbd)
      7c838d9e 6a00 push 0x0
      7c838da0 8d4510 lea eax,[ebp+0x10]
      7c838da3 50 push eax
      0:000> u
      kernel32!_lwrite+0x11:
      7c838da4 ff7510 push dword ptr [ebp+0x10]
      7c838da7 ff750c push dword ptr [ebp+0xc]
      7c838daa ff7508 push dword ptr [ebp+0x8]
      7c838dad e8ed81fdff call kernel32!WriteFile (7c810f9f)

      Pretty funny huh? I think u need to paste both code snipets. 8bc7c0ec02c0e404c0cc0680f7018827ebee

      B 1 Reply Last reply
      0
      • R r i s h a b h s

        Dear All, My application converts images of TIFF format to TIFFG3Fax. For this i'm using WriteFile sdk method to write data to the file. It fails. But when i use _lwrite, it works fine. Can someone tell me what is the differences between these two functions. _lwrite is obsolete so MSDN says that WriteFile should be used. But it fails with error code 183 (ERROR_ALREADY_EXISTS) Please help! Devoirs, ____________________________________________________________ rishabhs I think therefore I am.

        B Offline
        B Offline
        Bob Stanneveld
        wrote on last edited by
        #3

        those low level C functions wrap the WIN API. So if you would write windows apps for the 16 bit version, some of the code would still be usable, since it's still provided. If you used the 16 bit API however chances are that the code would become invalid since those function might no longer exist. If you look in implementation of STL, CRT functions or whatever library MS has written, in the end they all call the WIN API to do the job. So basically all the libraries all wrappers around the system specific API. Behind every great black man...             ... is the police. - Conspiracy brother Blog[^]

        A 1 Reply Last reply
        0
        • T Toby Opferman

          0:000> u kernel32!_lwrite
          kernel32!_lwrite:
          7c838d93 8bff mov edi,edi
          7c838d95 55 push ebp
          7c838d96 8bec mov ebp,esp
          7c838d98 837d1000 cmp dword ptr [ebp+0x10],0x0
          7c838d9c 741f jz kernel32!_lwrite+0x21 (7c838dbd)
          7c838d9e 6a00 push 0x0
          7c838da0 8d4510 lea eax,[ebp+0x10]
          7c838da3 50 push eax
          0:000> u
          kernel32!_lwrite+0x11:
          7c838da4 ff7510 push dword ptr [ebp+0x10]
          7c838da7 ff750c push dword ptr [ebp+0xc]
          7c838daa ff7508 push dword ptr [ebp+0x8]
          7c838dad e8ed81fdff call kernel32!WriteFile (7c810f9f)

          Pretty funny huh? I think u need to paste both code snipets. 8bc7c0ec02c0e404c0cc0680f7018827ebee

          B Offline
          B Offline
          Blake Miller
          wrote on last edited by
          #4

          Well, yes, that you went all the way to some disassembly :rolleyes: If you load the C run time source code and visually trace through it, you could see that all the 'standard' file IO calls typically devolve into CreateFile, ReadFile, WriteFile, and CloseHandle - after psending a fair bit of time mapping the fiol I/O flags and parameters into the ones that the Win32 API expects ;)

          T 1 Reply Last reply
          0
          • B Bob Stanneveld

            those low level C functions wrap the WIN API. So if you would write windows apps for the 16 bit version, some of the code would still be usable, since it's still provided. If you used the 16 bit API however chances are that the code would become invalid since those function might no longer exist. If you look in implementation of STL, CRT functions or whatever library MS has written, in the end they all call the WIN API to do the job. So basically all the libraries all wrappers around the system specific API. Behind every great black man...             ... is the police. - Conspiracy brother Blog[^]

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

            Thank you very much this information

            B R 2 Replies Last reply
            0
            • A Anonymous

              Thank you very much this information

              B Offline
              B Offline
              Bob Stanneveld
              wrote on last edited by
              #6

              You're welcome! :-D Behind every great black man...             ... is the police. - Conspiracy brother Blog[^]

              1 Reply Last reply
              0
              • B Blake Miller

                Well, yes, that you went all the way to some disassembly :rolleyes: If you load the C run time source code and visually trace through it, you could see that all the 'standard' file IO calls typically devolve into CreateFile, ReadFile, WriteFile, and CloseHandle - after psending a fair bit of time mapping the fiol I/O flags and parameters into the ones that the Win32 API expects ;)

                T Offline
                T Offline
                Toby Opferman
                wrote on last edited by
                #7

                Of course they are, that was the point :) 8bc7c0ec02c0e404c0cc0680f7018827ebee

                1 Reply Last reply
                0
                • A Anonymous

                  Thank you very much this information

                  R Offline
                  R Offline
                  r i s h a b h s
                  wrote on last edited by
                  #8

                  OOPS...i shows me as Anonymous. never mind. Once again thanks for your replies. Devoirs ____________________________________________________________ rishabhs I think therefore I am.

                  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