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'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