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. convert parameter from 'const int' to 'void *'

convert parameter from 'const int' to 'void *'

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
3 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.
  • C Offline
    C Offline
    CHYGO
    wrote on last edited by
    #1

    i difine a custom message(i want to post it to a driver) #define WM_INTERRUPT WM_USER+100 then i use it as a parameter in the function DeviceIoControl ... ULONG nBytesRead; if (! DeviceIoControl( m_hPCI9054, IOCTL_SET_NOTIFICATION_EVENT, &WM_INTERRUPT, sizeof(WM_INTERRUPT), NULL, 0, &nBytesRead, NULL ) ... it makes an error: ...'DeviceIoControl' : cannot convert parameter 3 from 'const int' to 'void *' how to fix it?

    i 've tried ,then i have no regret

    R S 2 Replies Last reply
    0
    • C CHYGO

      i difine a custom message(i want to post it to a driver) #define WM_INTERRUPT WM_USER+100 then i use it as a parameter in the function DeviceIoControl ... ULONG nBytesRead; if (! DeviceIoControl( m_hPCI9054, IOCTL_SET_NOTIFICATION_EVENT, &WM_INTERRUPT, sizeof(WM_INTERRUPT), NULL, 0, &nBytesRead, NULL ) ... it makes an error: ...'DeviceIoControl' : cannot convert parameter 3 from 'const int' to 'void *' how to fix it?

      i 've tried ,then i have no regret

      R Offline
      R Offline
      Rajasekharan Vengalil
      wrote on last edited by
      #2

      You have defined WM_INTERRUPT as a preprocessor symbol. During compilation, the compiler is going to simply replace all occurrences of WM_INTERRUPT with the number 1124. So what you're trying to do essentially, is this - &1124 which of course, does not make sense. Depending on how you have implemented your driver you can choose to pass WM_INTERRUPT directly like so - (void *)WM_INTERRUPT. This will of course, mean that you should not be dereferencing this value from your driver.

      -- gleat http://blogorama.nerdworks.in[^] --

      1 Reply Last reply
      0
      • C CHYGO

        i difine a custom message(i want to post it to a driver) #define WM_INTERRUPT WM_USER+100 then i use it as a parameter in the function DeviceIoControl ... ULONG nBytesRead; if (! DeviceIoControl( m_hPCI9054, IOCTL_SET_NOTIFICATION_EVENT, &WM_INTERRUPT, sizeof(WM_INTERRUPT), NULL, 0, &nBytesRead, NULL ) ... it makes an error: ...'DeviceIoControl' : cannot convert parameter 3 from 'const int' to 'void *' how to fix it?

        i 've tried ,then i have no regret

        S Offline
        S Offline
        Sarath C
        wrote on last edited by
        #3

        The parameter should not be constant as per the documentation. Do as follows LONG lData = WM_INTERRUPT; ULONG nBytesRead; if (! DeviceIoControl( m_hPCI9054, IOCTL_SET_NOTIFICATION_EVENT, &lData, sizeof(WM_INTERRUPT), NULL, 0, &nBytesRead, NULL )

        -Sarath. "Great hopes make everything great possible" - Benjamin Franklin

        My blog - Sharing My Thoughts

        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