tags:

views:

30

answers:

2

I am trying to use sendmessage of user32.dll in an embedded windows ce5.0 computer the same simple program that I made only for testing the user32 in embedded is working on my windows xp computer. the app and the dll are in the same folder.

the message I get when it is in win ce5.0 is : Can't find Pinvocke DLL 'user32.dll'

the code : (I find it in the web and used it to try the sendmessage)

    private int SC_MONITORPOWER = 0xF170;
    private int WM_SYSCOMMAND = 0x0112;

    [DllImport("user32.dll")]

    private static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);
    private void button3_Click(object sender, EventArgs e)
    {
        SendMessage(this.Handle.ToInt32(), WM_SYSCOMMAND, SC_MONITORPOWER, 2);
    }

can anyone help me with this?

A: 

SendMessage is defined in coredll.dll in Windows CE. See this link:

http://www.pinvoke.net/default.aspx/coredll.SendMessage

TheFogger
A: 

thanks for relpay so quick

I am not trying to turn the screen off this was an example to access an address in the computer so I was trying to do it, I am trying to use the watchdog of the board but it is not working. my board is an ICOP vortex86 board and they give me an example for the watchdog here http://www.dmp.com.tw/tech/os-wince/ this is the example : C Example Code for Windows CE

include "stdafx.h"

void outp(int addr, unsigned char val) { __asm { push edx mov edx, DWORD PTR addr mov al, BYTE PTR val out dx, al pop edx } } int main(int argc, char *argv[], char envp[]) { int nTime = 5; / set time out / outp(0x84a, nTime); / set timer clock to 1 second and "Timer Expiration Event 0/1" to reset system. */ outp(0x84b, 0x9c); printf("System will be reset after %d seconds.\n", nTime * 4); }

so I copied the sent values and did this in c#: private const int setTimeOut = 0x84a; private const int setTimeoutTo1a = 0x84b; private const int setTimeoutTo1b = 0x9c; private const int time = 5; [DllImport("coredll.dll")] public static extern int SendMessage(IntPtr hWnd, uint Msg, int wParam, int lParam); private void button3_Click(object sender, EventArgs e) { SendMessage((IntPtr)this.Handle.ToInt32(), setTimeOut, time,0); SendMessage((IntPtr)this.Handle.ToInt32(), setTimeoutTo1a, setTimeoutTo1b, 0); }

but didnt do anything is somthing wrong with what I am doing or watchdog is not working in this computer?

stl
This is a different question. Please open another question, instead of putting this in an answer.
TheFogger