Re: Mobile Service & Auto Start
- From: "<ctacke/>" <ctacke[@]opennetcf[dot]com>
- Date: Fri, 19 Jan 2007 18:18:06 -0500
You're also assuming that your change is flushed to the hive. If you make a
change, then save teh hives, it's quite possible that the change is not yet
persisted to the hive, so it would be expected that it would not be there on
restore. Try making the change, flushing, then doing the save and restore.
--
Chris Tacke
OpenNETCF Consulting
Managed Code in the Embedded World
www.opennetcf.com
--
"Jeremy" <Jeremy@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:E1DBA8BF-4E3E-49D0-AB36-EE398F9D5F04@xxxxxxxxxxxxxxxx
I tried doing RegCopyFile which creates a file and it appears to work. It
is
RegRestoreFile either fails or says it worked ok but then the registry
isnt
changed.
Like I go in and change the owner information then use the RegRestoreFile
and nothing. I am on an iPAQ hx2700 and a Palm Phone for testing neither
of
which seems to work, is there something else that needs to be done.
I even tried flushing the main keys after I did a RegRestoreFile and soft
and hard resets.
I see other people out there do it in like backup restore apps liks Spb
and
Sprite so I know it can be done, this whole solution is driving me insane,
thank you both very much for helping!!!
"<ctacke/>" wrote:
I know about those problems - I went in this morning, found and fixed
them
(IntPtr studpidly can't take a negative number). However they are real
simple functions (if you have the source take a look and you'll see).
They
just call RegCopyFile.
--
Chris Tacke
OpenNETCF Consulting
Managed Code in the Embedded World
www.opennetcf.com
--
"Jeremy" <Jeremy@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:6AA9DB72-6990-42E0-91DE-BF8D9473F2FE@xxxxxxxxxxxxxxxx
Thank you, you were very helpful, I noticed you mentioned somethin
about
points i there a way on hee to award poins for helping someone?
Also I have posted a few times out RegCopyFile and RegRestoreFile, and
I
see
yu ar from opennetcf it appears the RegistryHelper functions dont work
I
always get an eror saying "OverflowException" in the constructor for
IntPtr.
Do you know anything about those problems. RegCopyFile appears to work
it
generates a registry file for me then I change my owner info because I
notice
that was saved under currentuser and I do a RegRestoreFile and it
returns
true bu doesnt reset my owner info. I have tried flushing the base keys
and
even doing a soft and hard reset after I restore and nothing seems to
work.
Thanks again!
"Paul G. Tobey [eMVP]" wrote:
No, CeRunAppAtTime() should work in the emulator, for whatever that's
worth;
remember that it's an API for setting reminders, not a real-time call,
so
it
might be off by 30 seconds, depending on what else is going on.
Maybe
your
SYSTEMTIME is declared wrong. Or maybe you're passing GMT rather than
local
time?
Other than that, you'd have to be sure that the application is not
still
running, as I said (if calc is already running, a second copy won't be
started). I've never had any problems with the call on real devices.
The
only thing funny about it to me is the syntax for the "application
name"
when you want to have it fire an event, not start an application.
Paul T.
"Jeremy" <Jeremy@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:3D133A49-A72C-439A-B657-1B4D62D88AD5@xxxxxxxxxxxxxxxx
So I am guessing that the call just doesnt work in the emulator, I
finally
deployed my solution to my PDA and it worked. Thanks everyone for
all
of
your
help!
"Jeremy" wrote:
Oh I did have something to check for errors it was like:
if (!CeRunAppAtTime(SystemInfo.AppName, ref sysTime)) {
Win32Exception ex = new
Win32Exception(System.Runtime.InteropServices.Marshal.GetLastWin32Error());
MessageBox.Show("Error: "+ex.Message+" "+ex.ErrorCode+"
"+ex.NativeErrorCode);
}
It always returns true
"<ctacke/>" wrote:
Your assumption is incorrect. Once the notification is set, the
app
can
close an it should still execute as expected. What I'm not
seeing
is
you
checking the return from CeRunnAppAtTime to see if an error
occurred.
--
Chris Tacke
OpenNETCF Consulting
Managed Code in the Embedded World
www.opennetcf.com
--
"Jeremy" <Jeremy@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:549026C3-FCE4-4EEA-9BC0-6158FEE0CDCD@xxxxxxxxxxxxxxxx
First off let me say I really appreciate your help, usually I
post
on
msdn
and 6 weeks later someone gets back to me with something I
already
figured
out.
Now I have written quite a few mobile device apps, including a
lot
of
apps
that do pinvoke calls, but as I mentioned it does always seem
like
a
pain
to
find any good info on the pinvoke calls when they are needed.
up
till
now
I
have never needed to write an app like this and I just figured
since
i
have
written Windows Services before that do certain things at
certain
times,
or
because of certain events that it would not be difficult. Boy I
was
wrong.
The init thing works great, I just played with what exe inits
in
what
order
and that works out good for me with an implementation to unlock
a
service
from accessing a file and i knew I could always copy in the
contents
of
pim.vol from one file from another based on each individual
value
I
just
wanted to make it easy on myself.
Now as for this CeRunAppAtTime or
OpenNetCF.WindowsCE.Notification.NotifyRunAppAtTime which are
technically
both exactly the same by sending the app location and the
SYSTEMTIME
struct,
the only difference being is theres converts the datetime
object
where
mine
expects the SYSTEMTIME struct.
Now just that you do understand I do kinda know what I am
doing, I
am
really
just very dumb about the CeRunAppAtTime call and why it may not
work.
So I have an exe that I start 5 min after I push a button. Now
for
SAG I
use
calc.exe
and that didnt work either just to see if there was a problem
with
open my
exe.
I have:
[DllImport("coredll.dll", SetLastError=true)]
internal static extern bool CeRunAppAtTime(string appName, ref
SYSTEMTIME
time);
and a SYSTEMTIME struct.
and i call
CeRunAppAtTime(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase,
SYSTEMTIME.FromDateTime(DateTime.Now.AddMinutes(5));
Application.Exit();
----The above does nothing----
So this is what I am getting fom what you posted.
CeRunAppAtTime
doesnt
allow you to run an exe at a later time? I need it to run even
if
my
app
has
closed ( a real close using Application.Exit() not a minimize )
So
I
would
have to thread an exe that does nothing but define an event,
then
I
could
run
CeRunAppAtTime to execute an event within that exe which is
running
in the
background.
Is this correct?
This is one of the most confusing calls I have ever
encountered,
what
I
want
is a call that says
Execute "FileName.exe" at "DateTime" no matter what is going
on.
Let me know if I am correct in my assumption of what you
posted.
Thank you again!
"Paul G. Tobey [eMVP]" wrote:
I've replied on the registry and error code finding to the
last
message
because I didn't want those points to get lost...
Are you sure you *closed* your application? Remember that, on
Windows
Mobile devices, the X box on the title bar *does not close the
application*.
It minimizes it (called Smart Minimize, if you want to search
the
archives
for info).
As I mentioned in my original description of how I'd handle
this,
you
might
want to have CeRunAppAtTime() fire an event, not launch a
program.
OpenNETCF has a class library for doing that. Check the
Notify
class.
It's
in the Smart Device Framework 1.4, I know. Ah, here's the
sample
I
wrote
for firing an event at a time. I'll copy it below and
hopefully
it
won't
be
overly long...
Whoops, you started too close to the deadline! Always allow
several
months
for understanding a completely new technology! You'll hardly
ever
be
wrong.
Paul T.
----
code for form1.cs from notification sample of OpenNETCF. You
need
Smart
Device Framework (open source), 1.4 to use it.
/// This Notification sample uses the Notification Manager in
Windows
CE.NET
/// and later to notify the application that a given time of
day
has
been
/// reached via an event, rather than by launching the
application,
as
the
/// older version OSes will do. For this, you create a named
event,
call
/// CeRunAppAtTime() with a very special application name
parameter
(and
the
/// time at which the notification should fire, of course).
namespace Notification
{
using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.Data;
using OpenNETCF;
using OpenNETCF.Drawing;
using OpenNETCF.Windows.Forms;
using OpenNETCF.Win32;
using OpenNETCF.Win32.Notify;
using OpenNETCF.Threading;
.
- Follow-Ups:
- Re: Mobile Service & Auto Start
- From: Jeremy
- Re: Mobile Service & Auto Start
- References:
- Re: Mobile Service & Auto Start
- From: Jeremy
- Re: Mobile Service & Auto Start
- From: Paul G. Tobey [eMVP]
- Re: Mobile Service & Auto Start
- From: Jeremy
- Re: Mobile Service & Auto Start
- From: <ctacke/>
- Re: Mobile Service & Auto Start
- From: Jeremy
- Re: Mobile Service & Auto Start
- Prev by Date: Re: Mobile Service & Auto Start
- Next by Date: Re: Mobile Service & Auto Start
- Previous by thread: Re: Mobile Service & Auto Start
- Next by thread: Re: Mobile Service & Auto Start
- Index(es):