CeSetUserNotificationEx troubles

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • CR6485

    CeSetUserNotificationEx troubles

    Hi everyone,

    I've been trying out examples and reading documentation
    on CeSetUserNotifi cationEx for a couple days now and
    still cannot find the problem in my code. All I want to
    do is launch an application when the PPC wakes up. I'm
    deploying the solution on a Siemens SX56 with PPC
    3.0.12039.

    Here's my code. CeSetUserNotifi cationEx always returns
    me an IntPtr.Zero regardless of what I try.

    public class Utils
    {

    [DllImport("core dll.dll", SetLastError=tr ue)]
    private static extern IntPtr CeSetUserNotifi cationEx(
    IntPtr h,
    CE_NOTIFICATION _TRIGGER nt,
    CE_USER_NOTIFIC ATION un
    ) ;

    private unsafe class CE_NOTIFICATION _TRIGGER
    {
    public UInt32 dwSize;
    public UInt32 dwEvent;
    public UInt32 dwType;
    public char *lpszApplicatio n;
    public char *lpszArguments;
    public SystemTime startTime ;
    public SystemTime endTime ;
    }

    private unsafe class CE_USER_NOTIFIC ATION
    {
    public UInt32 ActionFlags ;
    public char *pDialogTitle ;
    public char *DialogText ;
    public char *Sound ;
    public UInt32 MaxSound ;
    public UInt32 Reserved ;
    }

    public struct SystemTime
    {
    public UInt16 Year ;
    public UInt16 Month ;
    public UInt16 DayOfWeek ;
    public UInt16 Day ;
    public UInt16 Hour ;
    public UInt16 Minute ;
    public UInt16 Second ;
    public UInt16 MilliSecond ;
    }

    struct Constants
    {
    public const int NOTIFICATION_EV ENT_NONE = 0;
    public const int CNT_EVENT = 1;
    public const int NOTIFICATION_EV ENT_WAKEUP = 11;
    }

    public unsafe static void AttachAppToStar tup(
    string executable, string arguments )
    {
    CE_NOTIFICATION _TRIGGER nt =
    new CE_NOTIFICATION _TRIGGER();
    CE_USER_NOTIFIC ATION un =
    new CE_USER_NOTIFIC ATION();
    IntPtr h;

    try
    {

    fixed( char *appName =
    executable.ToCh arArray() )
    {

    if( ( arguments == null ) ||
    ( arguments.Lengt h == 0 ) )
    {
    arguments = " ";
    }

    fixed( char *appArgs =
    arguments.ToCha rArray() )
    {

    nt.dwSize = (uint)Marshal.S izeOf( typeof
    (CE_NOTIFICATIO N_TRIGGER) );
    nt.dwType = Constants.CNT_E VENT;
    nt.dwEvent = Constants.NOTIF ICATION_EVENT_N ONE;
    nt.lpszApplicat ion = appName;
    nt.lpszArgument s = appArgs;

    h = CeSetUserNotifi cationEx(IntPtr .Zero, nt, un) ;

    MessageBox.Show ( "h is " +
    ( (h!=IntPtr.Zero ) ? "not " : "" ) +
    "null." );

    }
    }
    }
    catch( Exception E )
    {
    MessageBox.Show ( E.ToString() );
    }
    }

    }

    --------------------------

    This is the method in a Windows Form object that calls
    the wrapper.

    private void menuItem1_Click
    (object sender, System.EventArg s e)
    {
    string executable =
    Assembly.GetExe cutingAssembly( ).GetModules()
    [0].FullyQualified Name;
    Utils.AttachApp ToStartup( executable, null );
    }

    I appreciate any help you can provide!

    CR
  • Ignacio Machin

    #2
    Re: CeSetUserNotifi cationEx troubles

    Hi,

    Take a look at http://www.innovativedss.com/forums/...p?TOPIC_ID=127

    also , I think that you will find better answers in the
    microsoft.publi c.dotnet.framew ork.compactfram ework NG

    Hope this help,

    --
    Ignacio Machin,
    ignacio.machin AT dot.state.fl.us
    Florida Department Of Transportation

    "CR6485" <fenderdg20@hot mail.com> wrote in message
    news:0a7a01c347 0c$6a51c7f0$a00 1280a@phx.gbl.. .[color=blue]
    > Hi everyone,
    >
    > I've been trying out examples and reading documentation
    > on CeSetUserNotifi cationEx for a couple days now and
    > still cannot find the problem in my code. All I want to
    > do is launch an application when the PPC wakes up. I'm
    > deploying the solution on a Siemens SX56 with PPC
    > 3.0.12039.
    >
    > Here's my code. CeSetUserNotifi cationEx always returns
    > me an IntPtr.Zero regardless of what I try.
    >
    > public class Utils
    > {
    >
    > [DllImport("core dll.dll", SetLastError=tr ue)]
    > private static extern IntPtr CeSetUserNotifi cationEx(
    > IntPtr h,
    > CE_NOTIFICATION _TRIGGER nt,
    > CE_USER_NOTIFIC ATION un
    > ) ;
    >
    > private unsafe class CE_NOTIFICATION _TRIGGER
    > {
    > public UInt32 dwSize;
    > public UInt32 dwEvent;
    > public UInt32 dwType;
    > public char *lpszApplicatio n;
    > public char *lpszArguments;
    > public SystemTime startTime ;
    > public SystemTime endTime ;
    > }
    >
    > private unsafe class CE_USER_NOTIFIC ATION
    > {
    > public UInt32 ActionFlags ;
    > public char *pDialogTitle ;
    > public char *DialogText ;
    > public char *Sound ;
    > public UInt32 MaxSound ;
    > public UInt32 Reserved ;
    > }
    >
    > public struct SystemTime
    > {
    > public UInt16 Year ;
    > public UInt16 Month ;
    > public UInt16 DayOfWeek ;
    > public UInt16 Day ;
    > public UInt16 Hour ;
    > public UInt16 Minute ;
    > public UInt16 Second ;
    > public UInt16 MilliSecond ;
    > }
    >
    > struct Constants
    > {
    > public const int NOTIFICATION_EV ENT_NONE = 0;
    > public const int CNT_EVENT = 1;
    > public const int NOTIFICATION_EV ENT_WAKEUP = 11;
    > }
    >
    > public unsafe static void AttachAppToStar tup(
    > string executable, string arguments )
    > {
    > CE_NOTIFICATION _TRIGGER nt =
    > new CE_NOTIFICATION _TRIGGER();
    > CE_USER_NOTIFIC ATION un =
    > new CE_USER_NOTIFIC ATION();
    > IntPtr h;
    >
    > try
    > {
    >
    > fixed( char *appName =
    > executable.ToCh arArray() )
    > {
    >
    > if( ( arguments == null ) ||
    > ( arguments.Lengt h == 0 ) )
    > {
    > arguments = " ";
    > }
    >
    > fixed( char *appArgs =
    > arguments.ToCha rArray() )
    > {
    >
    > nt.dwSize = (uint)Marshal.S izeOf( typeof
    > (CE_NOTIFICATIO N_TRIGGER) );
    > nt.dwType = Constants.CNT_E VENT;
    > nt.dwEvent = Constants.NOTIF ICATION_EVENT_N ONE;
    > nt.lpszApplicat ion = appName;
    > nt.lpszArgument s = appArgs;
    >
    > h = CeSetUserNotifi cationEx(IntPtr .Zero, nt, un) ;
    >
    > MessageBox.Show ( "h is " +
    > ( (h!=IntPtr.Zero ) ? "not " : "" ) +
    > "null." );
    >
    > }
    > }
    > }
    > catch( Exception E )
    > {
    > MessageBox.Show ( E.ToString() );
    > }
    > }
    >
    > }
    >
    > --------------------------
    >
    > This is the method in a Windows Form object that calls
    > the wrapper.
    >
    > private void menuItem1_Click
    > (object sender, System.EventArg s e)
    > {
    > string executable =
    > Assembly.GetExe cutingAssembly( ).GetModules()
    > [0].FullyQualified Name;
    > Utils.AttachApp ToStartup( executable, null );
    > }
    >
    > I appreciate any help you can provide!
    >
    > CR[/color]


    Comment

    • CR6485

      #3
      Re: CeSetUserNotifi cationEx troubles

      I'll give it a shot.

      Thanks!
      [color=blue]
      >-----Original Message-----
      >Hi,
      >
      > Take a look at[/color]
      http://www.innovativedss.com/forums/...p?TOPIC_ID=127[color=blue]
      >
      >also , I think that you will find better answers in the
      >microsoft.publ ic.dotnet.frame work.compactfra mework NG
      >
      >Hope this help,
      >
      >--
      >Ignacio Machin,
      >ignacio.mach in AT dot.state.fl.us
      >Florida Department Of Transportation
      >
      >"CR6485" <fenderdg20@hot mail.com> wrote in message
      >news:0a7a01c34 70c$6a51c7f0$a0 01280a@phx.gbl. ..[color=green]
      >> Hi everyone,
      >>
      >> I've been trying out examples and reading documentation
      >> on CeSetUserNotifi cationEx for a couple days now and
      >> still cannot find the problem in my code. All I want[/color][/color]
      to[color=blue][color=green]
      >> do is launch an application when the PPC wakes up. I'm
      >> deploying the solution on a Siemens SX56 with PPC
      >> 3.0.12039.
      >>
      >> Here's my code. CeSetUserNotifi cationEx always returns
      >> me an IntPtr.Zero regardless of what I try.
      >>
      >> public class Utils
      >> {
      >>
      >> [DllImport("core dll.dll", SetLastError=tr ue)]
      >> private static extern IntPtr CeSetUserNotifi cationEx(
      >> IntPtr h,
      >> CE_NOTIFICATION _TRIGGER nt,
      >> CE_USER_NOTIFIC ATION un
      >> ) ;
      >>
      >> private unsafe class CE_NOTIFICATION _TRIGGER
      >> {
      >> public UInt32 dwSize;
      >> public UInt32 dwEvent;
      >> public UInt32 dwType;
      >> public char *lpszApplicatio n;
      >> public char *lpszArguments;
      >> public SystemTime startTime ;
      >> public SystemTime endTime ;
      >> }
      >>
      >> private unsafe class CE_USER_NOTIFIC ATION
      >> {
      >> public UInt32 ActionFlags ;
      >> public char *pDialogTitle ;
      >> public char *DialogText ;
      >> public char *Sound ;
      >> public UInt32 MaxSound ;
      >> public UInt32 Reserved ;
      >> }
      >>
      >> public struct SystemTime
      >> {
      >> public UInt16 Year ;
      >> public UInt16 Month ;
      >> public UInt16 DayOfWeek ;
      >> public UInt16 Day ;
      >> public UInt16 Hour ;
      >> public UInt16 Minute ;
      >> public UInt16 Second ;
      >> public UInt16 MilliSecond ;
      >> }
      >>
      >> struct Constants
      >> {
      >> public const int NOTIFICATION_EV ENT_NONE = 0;
      >> public const int CNT_EVENT = 1;
      >> public const int NOTIFICATION_EV ENT_WAKEUP = 11;
      >> }
      >>
      >> public unsafe static void AttachAppToStar tup(
      >> string executable, string arguments )
      >> {
      >> CE_NOTIFICATION _TRIGGER nt =
      >> new CE_NOTIFICATION _TRIGGER();
      >> CE_USER_NOTIFIC ATION un =
      >> new CE_USER_NOTIFIC ATION();
      >> IntPtr h;
      >>
      >> try
      >> {
      >>
      >> fixed( char *appName =
      >> executable.ToCh arArray() )
      >> {
      >>
      >> if( ( arguments == null ) ||
      >> ( arguments.Lengt h == 0 ) )
      >> {
      >> arguments = " ";
      >> }
      >>
      >> fixed( char *appArgs =
      >> arguments.ToCha rArray() )
      >> {
      >>
      >> nt.dwSize = (uint)Marshal.S izeOf( typeof
      >> (CE_NOTIFICATIO N_TRIGGER) );
      >> nt.dwType = Constants.CNT_E VENT;
      >> nt.dwEvent = Constants.NOTIF ICATION_EVENT_N ONE;
      >> nt.lpszApplicat ion = appName;
      >> nt.lpszArgument s = appArgs;
      >>
      >> h = CeSetUserNotifi cationEx(IntPtr .Zero, nt,[/color][/color]
      un) ;[color=blue][color=green]
      >>
      >> MessageBox.Show ( "h is " +
      >> ( (h!=IntPtr.Zero ) ? "not " : "" ) +
      >> "null." );
      >>
      >> }
      >> }
      >> }
      >> catch( Exception E )
      >> {
      >> MessageBox.Show ( E.ToString() );
      >> }
      >> }
      >>
      >> }
      >>
      >> --------------------------
      >>
      >> This is the method in a Windows Form object that calls
      >> the wrapper.
      >>
      >> private void menuItem1_Click
      >> (object sender, System.EventArg s e)
      >> {
      >> string executable =
      >> Assembly.GetExe cutingAssembly( ).GetModules()
      >> [0].FullyQualified Name;
      >> Utils.AttachApp ToStartup( executable, null );
      >> }
      >>
      >> I appreciate any help you can provide!
      >>
      >> CR[/color]
      >
      >
      >.
      >[/color]

      Comment

      Working...