CeSetUserNotificationEx troubles

C

CR6485

Hi everyone,

I've been trying out examples and reading documentation
on CeSetUserNotificationEx 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. CeSetUserNotificationEx always returns
me an IntPtr.Zero regardless of what I try.

public class Utils
{

[DllImport("coredll.dll", SetLastError=true)]
private static extern IntPtr CeSetUserNotificationEx(
IntPtr h,
CE_NOTIFICATION_TRIGGER nt,
CE_USER_NOTIFICATION un
) ;

private unsafe class CE_NOTIFICATION_TRIGGER
{
public UInt32 dwSize;
public UInt32 dwEvent;
public UInt32 dwType;
public char *lpszApplication;
public char *lpszArguments;
public SystemTime startTime ;
public SystemTime endTime ;
}

private unsafe class CE_USER_NOTIFICATION
{
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_EVENT_NONE = 0;
public const int CNT_EVENT = 1;
public const int NOTIFICATION_EVENT_WAKEUP = 11;
}

public unsafe static void AttachAppToStartup(
string executable, string arguments )
{
CE_NOTIFICATION_TRIGGER nt =
new CE_NOTIFICATION_TRIGGER();
CE_USER_NOTIFICATION un =
new CE_USER_NOTIFICATION();
IntPtr h;

try
{

fixed( char *appName =
executable.ToCharArray() )
{

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

fixed( char *appArgs =
arguments.ToCharArray() )
{

nt.dwSize = (uint)Marshal.SizeOf( typeof
(CE_NOTIFICATION_TRIGGER) );
nt.dwType = Constants.CNT_EVENT;
nt.dwEvent = Constants.NOTIFICATION_EVENT_NONE;
nt.lpszApplication = appName;
nt.lpszArguments = appArgs;

h = CeSetUserNotificationEx(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.EventArgs e)
{
string executable =
Assembly.GetExecutingAssembly().GetModules()
[0].FullyQualifiedName;
Utils.AttachAppToStartup( executable, null );
}

I appreciate any help you can provide!

CR
 
I

Ignacio Machin

Hi,

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

also , I think that you will find better answers in the
microsoft.public.dotnet.framework.compactframework NG

Hope this help,

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

CR6485 said:
Hi everyone,

I've been trying out examples and reading documentation
on CeSetUserNotificationEx 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. CeSetUserNotificationEx always returns
me an IntPtr.Zero regardless of what I try.

public class Utils
{

[DllImport("coredll.dll", SetLastError=true)]
private static extern IntPtr CeSetUserNotificationEx(
IntPtr h,
CE_NOTIFICATION_TRIGGER nt,
CE_USER_NOTIFICATION un
) ;

private unsafe class CE_NOTIFICATION_TRIGGER
{
public UInt32 dwSize;
public UInt32 dwEvent;
public UInt32 dwType;
public char *lpszApplication;
public char *lpszArguments;
public SystemTime startTime ;
public SystemTime endTime ;
}

private unsafe class CE_USER_NOTIFICATION
{
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_EVENT_NONE = 0;
public const int CNT_EVENT = 1;
public const int NOTIFICATION_EVENT_WAKEUP = 11;
}

public unsafe static void AttachAppToStartup(
string executable, string arguments )
{
CE_NOTIFICATION_TRIGGER nt =
new CE_NOTIFICATION_TRIGGER();
CE_USER_NOTIFICATION un =
new CE_USER_NOTIFICATION();
IntPtr h;

try
{

fixed( char *appName =
executable.ToCharArray() )
{

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

fixed( char *appArgs =
arguments.ToCharArray() )
{

nt.dwSize = (uint)Marshal.SizeOf( typeof
(CE_NOTIFICATION_TRIGGER) );
nt.dwType = Constants.CNT_EVENT;
nt.dwEvent = Constants.NOTIFICATION_EVENT_NONE;
nt.lpszApplication = appName;
nt.lpszArguments = appArgs;

h = CeSetUserNotificationEx(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.EventArgs e)
{
string executable =
Assembly.GetExecutingAssembly().GetModules()
[0].FullyQualifiedName;
Utils.AttachAppToStartup( executable, null );
}

I appreciate any help you can provide!

CR
 
C

CR6485

I'll give it a shot.

Thanks!
-----Original Message-----
Hi,

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

also , I think that you will find better answers in the
microsoft.public.dotnet.framework.compactframework NG

Hope this help,

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

CR6485 said:
Hi everyone,

I've been trying out examples and reading documentation
on CeSetUserNotificationEx 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. CeSetUserNotificationEx always returns
me an IntPtr.Zero regardless of what I try.

public class Utils
{

[DllImport("coredll.dll", SetLastError=true)]
private static extern IntPtr CeSetUserNotificationEx(
IntPtr h,
CE_NOTIFICATION_TRIGGER nt,
CE_USER_NOTIFICATION un
) ;

private unsafe class CE_NOTIFICATION_TRIGGER
{
public UInt32 dwSize;
public UInt32 dwEvent;
public UInt32 dwType;
public char *lpszApplication;
public char *lpszArguments;
public SystemTime startTime ;
public SystemTime endTime ;
}

private unsafe class CE_USER_NOTIFICATION
{
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_EVENT_NONE = 0;
public const int CNT_EVENT = 1;
public const int NOTIFICATION_EVENT_WAKEUP = 11;
}

public unsafe static void AttachAppToStartup(
string executable, string arguments )
{
CE_NOTIFICATION_TRIGGER nt =
new CE_NOTIFICATION_TRIGGER();
CE_USER_NOTIFICATION un =
new CE_USER_NOTIFICATION();
IntPtr h;

try
{

fixed( char *appName =
executable.ToCharArray() )
{

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

fixed( char *appArgs =
arguments.ToCharArray() )
{

nt.dwSize = (uint)Marshal.SizeOf( typeof
(CE_NOTIFICATION_TRIGGER) );
nt.dwType = Constants.CNT_EVENT;
nt.dwEvent = Constants.NOTIFICATION_EVENT_NONE;
nt.lpszApplication = appName;
nt.lpszArguments = appArgs;

h = CeSetUserNotificationEx(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.EventArgs e)
{
string executable =
Assembly.GetExecutingAssembly().GetModules()
[0].FullyQualifiedName;
Utils.AttachAppToStartup( executable, null );
}

I appreciate any help you can provide!

CR


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top