Device vs Emulator deploy

  • Thread starter Thread starter jayderk
  • Start date Start date
J

jayderk

Hello All,

I am pretty sure the question has been asked before, but I couldn't find it.

I want to be able to deploy my app (with no code change) to emulator or my
CE4.1 device.
my 4.1 device has some hardware that is not on the emulator(and I don't need
it on the emulator).

I would like something like this
#if 'I am not using the emulator'
hardware_device.initialize();
#endif

private void useHardware()
{
this.doOtherStuff();
#if 'I am not using the emulator'
hardware_device.usethis();
#endif
}

thanks in advanced
Jay
 
You could try calling LoadLibrary() on your DLL that controls the hardware
and only do the other operations if it's successful (you'll want to call
FreeLibrary() on the handle returned, too, if it's successful, I think).
LoadLibrary() just takes one parameter, the path to the DLL, and returns a
handle, which you can represent in managed code with an IntPtr.
FreeLibrary() takes this handle as its only parameter.

Paul T.
 
Hello Paul,
my problem isn't so much the libraries, it is with the declarations and the
functions being called.....
so if could in-effect comment out parts of my code when I use the emulator..

thanks,
Jay
 
I'm just saying:

IntPtr dll = Whatever.LoadLibrary( "MyDll.dll" );
bool dllPresent = ( dll != 0 ); // I haven't actually verified
// that this is
the right form of this
// operation

if ( dllPresent )
{
// Do whatever on the real device...

Whatever.FreeLibrary( dll );
}

Paul T.
 
Back
Top