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. HANDLE, DWROD please help newbiew

HANDLE, DWROD please help newbiew

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
4 Posts 4 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
    afil6545
    wrote on last edited by
    #1

    Hello gurus, Please be patient with a newbie. Everywhere I look on the web I see code with these strange vriable types written in capitals like "DWORD" or "HANDLE". Pleople just declare them without having a class of type dword or handle. When I try to use such code, ofcourse the compiler says: 'DWORD' : undeclared identifier I am trying to use a function called CreateFile which has the attributes: HANDLE CreateFile( LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDispostion, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile ); It return type is "HANDLE". What the? Theres no such thing. Is it an int? MSDN says that "dwDesiredAcess" has to be either 0, GENERIC_READ or GENERIC_WRITE. Is GENERIC_READ a string or what? When I try to use the the function. ie: hComm = CreateFile(portname, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0); The compiler says: 'GENERIC_READ' : undeclared identifier. Look, this is a basic question that has porbably been answered elsewhere? But what am I supposed to search for? "variable types written in CAPITALS"? Pleas help.

    P B 2 Replies Last reply
    0
    • A afil6545

      Hello gurus, Please be patient with a newbie. Everywhere I look on the web I see code with these strange vriable types written in capitals like "DWORD" or "HANDLE". Pleople just declare them without having a class of type dword or handle. When I try to use such code, ofcourse the compiler says: 'DWORD' : undeclared identifier I am trying to use a function called CreateFile which has the attributes: HANDLE CreateFile( LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDispostion, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile ); It return type is "HANDLE". What the? Theres no such thing. Is it an int? MSDN says that "dwDesiredAcess" has to be either 0, GENERIC_READ or GENERIC_WRITE. Is GENERIC_READ a string or what? When I try to use the the function. ie: hComm = CreateFile(portname, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0); The compiler says: 'GENERIC_READ' : undeclared identifier. Look, this is a basic question that has porbably been answered elsewhere? But what am I supposed to search for? "variable types written in CAPITALS"? Pleas help.

      P Offline
      P Offline
      Priyank Bolia
      wrote on last edited by
      #2

      DWORD is just a typedef for unsigned long: typedef unsigned long DWORD; HANDLE is just a typedef for void* typedef void *HANDLE; handle is a kind of pointer to the windows objects, like bitmaps, brush, etc. http://www.priyank.in/

      C 1 Reply Last reply
      0
      • A afil6545

        Hello gurus, Please be patient with a newbie. Everywhere I look on the web I see code with these strange vriable types written in capitals like "DWORD" or "HANDLE". Pleople just declare them without having a class of type dword or handle. When I try to use such code, ofcourse the compiler says: 'DWORD' : undeclared identifier I am trying to use a function called CreateFile which has the attributes: HANDLE CreateFile( LPCTSTR lpFileName, DWORD dwDesiredAccess, DWORD dwShareMode, LPSECURITY_ATTRIBUTES lpSecurityAttributes, DWORD dwCreationDispostion, DWORD dwFlagsAndAttributes, HANDLE hTemplateFile ); It return type is "HANDLE". What the? Theres no such thing. Is it an int? MSDN says that "dwDesiredAcess" has to be either 0, GENERIC_READ or GENERIC_WRITE. Is GENERIC_READ a string or what? When I try to use the the function. ie: hComm = CreateFile(portname, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0); The compiler says: 'GENERIC_READ' : undeclared identifier. Look, this is a basic question that has porbably been answered elsewhere? But what am I supposed to search for? "variable types written in CAPITALS"? Pleas help.

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

        Hello, Try: #include <windows.h> ans see the magic that can do! About those types, they are all typedefs by microsoft. All the types that have 'WORD' in their name, are somekind of an int: WORD = 2 bytes unsigned integer, DWORD = 4 bytes unsigned integer and QWORD (Quad WORD) is left as a exercise... The HANDLE object is a void* pointer to a system object that is managed by windows. The more windows programming you do, the more you see those objects. Once you learn how to read the MS conventions (try the hongarian notation) some of those names become more easy to read. For example: LPCTSTR becomes something like: Long Pointer Constant T (unicode, when defined) STRing, where T comes from the macro _T that you use to make unicode strings if you do a unicode build. I hope that things are more clear now. Good luck on your quest! I also got the blogging virus..[^]

        1 Reply Last reply
        0
        • P Priyank Bolia

          DWORD is just a typedef for unsigned long: typedef unsigned long DWORD; HANDLE is just a typedef for void* typedef void *HANDLE; handle is a kind of pointer to the windows objects, like bitmaps, brush, etc. http://www.priyank.in/

          C Offline
          C Offline
          CP Visitor
          wrote on last edited by
          #4

          Priyank Bolia wrote: HANDLE is just a typedef for void* typedef void *HANDLE; not always: see WINNT.H

          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