how do I use SDF 2.0

  • Thread starter Thread starter chad
  • Start date Start date
C

chad

I have been trying to install SDF 2.0 to learn about the options it
has, Could someone help me import the SDF 2.0 into my Project? I'm new
to C# and and i'm having problems getting my project to see the Dlls.

Thanks for your Help!
 
You should be able to just Add Reference and they should appear in the list.
If they don't, we'd like to know that.

-Chris
 
Chris thanks for your response!

I have another question about deploying the dlls to the PDA. I'm trying
to use the OpenNETCF dll with the Diagnostics component. The function
i'm using is the Process.Start function to call an EXE.

The code build without errors, but does not call the EXE on the PDA
when I test it or throw errors. It just steps over the code as if it
was never there.

Example code:

String Scanner= "\\Application\\ScanWedge.exe";

Process.Start(startScanner);

Do you have any idea way this would happen?

Thanks!

Chad
 
Show us the value of startScanner variable and an exception that you got.

I believe startScanner is not initialized thus you get an exception.
 
Why are you using SDF instead of just making the call in your own code?

// Opens Today dialog on PocketPC to show item settings
using System;
using System.Runtime.InteropServices;

namespace Show_Today_Items_Settings{

public class ProcessInfo {
public System.Int32 hProcess;
public System.Int32 hThread;
public System.Int32 ProcessID;
public System.Int32 ThreadID;
}

class ShowTodayItemsSettings {
[DllImport("coredll.Dll")]
private static extern int CreateProcess(
string strImageName,
string strCmdLine,
IntPtr pProcessAttributes,
IntPtr pThreadAttributes ,
int bInheritsHandle,
int dwCreationFlags,
IntPtr pEnvironment,
IntPtr pCurrentDir,
Byte[] bArray,
ProcessInfo oProc);

private static void ShowItemsSettings(){
ProcessInfo pi = new ProcessInfo();
CreateProcess("ctlpnl", "cplmain.cpl,13,1", IntPtr.Zero, IntPtr.Zero, 0,
0, IntPtr.Zero, IntPtr.Zero, new Byte[128], pi);
}

public static void Main(string[] args){
ShowItemsSettings();
}

}

}
 
Thanks for your Response Sergey!

Sorry I miss posted the "startScanner" variable.

String startScanner = "\\Application\\ScanWedge.exe";

Process.Start(startScanner);

Plus there is no exception thrown, and the ScanWedge.exe does not START
on the PDA.

So I have to start the ScanWedge.exe manually.

I also double checked the path, but if the path was not right wouldn't
I get an exception?

Thanks Again for the help!

Chad
 
No, it will not throw an exception if the path is incorrect. I just
thought that you are passing uninitialized variable.

The code looks good - I just can suggest to double check the path again...
 
CF 2.0 also offers:

#region ShellExecute ~~~~~~~~~~~~~~~~~~~~~
/// <summary>
/// Attempt to start another exe
/// </summary>
/// <param name="ExeName"></param>
/// <param name="CmdLine"></param>
/// <returns></returns>
public static bool ShellExecute( String ExeName, String CmdLine)
{
System.Diagnostics.Process p = null;
p = System.Diagnostics.Process.Start(ExeName, CmdLine);
return p.Id != 0;
}
#endregion
 
Probably becasue there's no point in reinventing the wheel. By your logic,
why do anything with the CF classes when you can P/Invoke? Why even use the
CF when you can write in C? Why do it in C when you can write assembler?
Why even use an operating system, why not write assembly commands right to
the processor?

-Chris


Brooke said:
Why are you using SDF instead of just making the call in your own code?

// Opens Today dialog on PocketPC to show item settings
using System;
using System.Runtime.InteropServices;

namespace Show_Today_Items_Settings{

public class ProcessInfo {
public System.Int32 hProcess;
public System.Int32 hThread;
public System.Int32 ProcessID;
public System.Int32 ThreadID;
}

class ShowTodayItemsSettings {
[DllImport("coredll.Dll")]
private static extern int CreateProcess(
string strImageName,
string strCmdLine,
IntPtr pProcessAttributes,
IntPtr pThreadAttributes ,
int bInheritsHandle,
int dwCreationFlags,
IntPtr pEnvironment,
IntPtr pCurrentDir,
Byte[] bArray,
ProcessInfo oProc);

private static void ShowItemsSettings(){
ProcessInfo pi = new ProcessInfo();
CreateProcess("ctlpnl", "cplmain.cpl,13,1", IntPtr.Zero, IntPtr.Zero, 0,
0, IntPtr.Zero, IntPtr.Zero, new Byte[128], pi);
}

public static void Main(string[] args){
ShowItemsSettings();
}

}

}


chad said:
Chris thanks for your response!

I have another question about deploying the dlls to the PDA. I'm trying
to use the OpenNETCF dll with the Diagnostics component. The function
i'm using is the Process.Start function to call an EXE.

The code build without errors, but does not call the EXE on the PDA
when I test it or throw errors. It just steps over the code as if it
was never there.

Example code:

String Scanner= "\\Application\\ScanWedge.exe";

Process.Start(startScanner);

Do you have any idea way this would happen?

Thanks!

Chad
 
I got it to work but I had to use the following path. No idea why I
needed the "//" in front of the path. but it works.


String startScanner = "//\\Application\\ScanWedge.exe";


Process.Start(startScanner);
 
My ScanWedge.exe resides in the Utils folder. This is what I use in C#:

Process.Start(@"\Program Files\Utils\ScanWedge.exe");

P.S. For those who are still using Visual Studio 2003 (as I am),
www.OpenNETCF.org provides lots of libraries (compiled dlls and source)
that extend the features of .NET CF 1.0, including OpenNETCF.dll that
has the OpenNETCF.Diagnostics.Process class.
 
Back
Top