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#
  4. SendMessage return value

SendMessage return value

Scheduled Pinned Locked Moved C#
question
4 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.
  • S Offline
    S Offline
    status
    wrote on last edited by
    #1

    Hello, i'm using SendMessage winapi function in my program like this: [DllImport("user32.dll", SetLastError=true, EntryPoint="SendMessage", CharSet=CharSet.Auto)] public static extern IntPtr SendMessage( IntPtr hWnd, [MarshalAs(UnmanagedType.U4)] int Msg, long wParam, int lParam); So i'm executing it and i want to use the returned value. But it seems that the returned value is a pointer. How can i get the value? The code is like this: IntPtr hWnd = FindWindow("Winamp v1.x", null); IntPtr lResult = SendMessage(hWnd, WM_WA_IPC, 0, IPC_GETEQDATA); -- modified at 9:38 Thursday 6th October, 2005

    S 2 Replies Last reply
    0
    • S status

      Hello, i'm using SendMessage winapi function in my program like this: [DllImport("user32.dll", SetLastError=true, EntryPoint="SendMessage", CharSet=CharSet.Auto)] public static extern IntPtr SendMessage( IntPtr hWnd, [MarshalAs(UnmanagedType.U4)] int Msg, long wParam, int lParam); So i'm executing it and i want to use the returned value. But it seems that the returned value is a pointer. How can i get the value? The code is like this: IntPtr hWnd = FindWindow("Winamp v1.x", null); IntPtr lResult = SendMessage(hWnd, WM_WA_IPC, 0, IPC_GETEQDATA); -- modified at 9:38 Thursday 6th October, 2005

      S Offline
      S Offline
      status
      wrote on last edited by
      #2

      Hmm, may be the problem isn't in the returned type. But when i try this code in c++ it is working and the return value is correct, but in .NET i'm always receiving 20496

      1 Reply Last reply
      0
      • S status

        Hello, i'm using SendMessage winapi function in my program like this: [DllImport("user32.dll", SetLastError=true, EntryPoint="SendMessage", CharSet=CharSet.Auto)] public static extern IntPtr SendMessage( IntPtr hWnd, [MarshalAs(UnmanagedType.U4)] int Msg, long wParam, int lParam); So i'm executing it and i want to use the returned value. But it seems that the returned value is a pointer. How can i get the value? The code is like this: IntPtr hWnd = FindWindow("Winamp v1.x", null); IntPtr lResult = SendMessage(hWnd, WM_WA_IPC, 0, IPC_GETEQDATA); -- modified at 9:38 Thursday 6th October, 2005

        S Offline
        S Offline
        status
        wrote on last edited by
        #3

        I found my problem. It is in the SendMessage declaration. The parameters should be IntPtr instead long and int: [DllImport("user32.dll", SetLastError=true, EntryPoint="SendMessage", CharSet = CharSet.Auto)] public static extern IntPtr SendMessage( IntPtr hWnd, [MarshalAs(UnmanagedType.U4)] int Msg, IntPtr wParam, IntPtr lParam);

        M 1 Reply Last reply
        0
        • S status

          I found my problem. It is in the SendMessage declaration. The parameters should be IntPtr instead long and int: [DllImport("user32.dll", SetLastError=true, EntryPoint="SendMessage", CharSet = CharSet.Auto)] public static extern IntPtr SendMessage( IntPtr hWnd, [MarshalAs(UnmanagedType.U4)] int Msg, IntPtr wParam, IntPtr lParam);

          M Offline
          M Offline
          mav northwind
          wrote on last edited by
          #4

          Small correction: You _can_ use int. The only thing that was causing troubles was the long declaration, since longs in .NET are 8 byte and not 4 like WPARAM. Oh, and the [MarshalAs...] declaration is superfluous, btw. Regards, mav

          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