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