Setting a default application in pocket PC

Hi,

We have developed an application in C# .Net Compact Framework using .NET Visual Studio 2003 and have it running on the Pocket PC(HP iPaq 5555) as well.

I have 2 requirements :

1)I need to make this application the default application that is launched when pocket pc starts up

2)Need to disable all other applications / other windows programs when this application is running.

Any ideas on how to do the same?

Thanks

Smitha

[475 byte] By [SmithaAjay] at [2007-12-23]
# 1

I guess you can place a shortcut to the application in the startup folder of the device, this will startup the application upon starting up the device.

as for #2 - I don't know im afraid.

hope the answer to Q#1 helps

ahmedilyas at 2007-8-30 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 2
This has been asked numerous times on this forum. Search for "kiosk" for a list of relevant threads.
timg_msft at 2007-8-30 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 3

1)Any idea how to place the shortcut in the startup folder of a pocket pc ?Unable to find the start up folder..am new to using the pocket pc and hence i guess the most obvious is seeming not v clear?

2)I had a look at the kiosk modes for the application and that seems to be to disable the hardware keys of the application.Should i integrate that in my application code to make sure that the user doesnt accidentaly start up any other program?

Thanks for answering my basic questions..just started learning the CF.

Smitha

SmithaAjay at 2007-8-30 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 4

1)Any idea how to place the shortcut in the startup folder of a pocket pc ?Unable to find the start up folder..am new to using the pocket pc and hence i guess the most obvious is seeming not v clear?

2)I had a look at the kiosk modes for the application and that seems to be to disable the hardware keys of the application.Should i integrate that in my application code to make sure that the user doesnt accidentaly start up any other program?

Thanks for answering my basic questions..just started learning the CF.

Smitha

SmithaAjay at 2007-8-30 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 5

Actually, in addition to disabling the handware buttons, i also need to prevent the user from getting to access the 'Start' menu in the pocket pc.

Any idea how to do that?

I still havent figured how to get to the startup in the pocket pc and set a shortcut there.

Any help is appreciated.

Thanks

Smitha

SmithaAjay at 2007-8-30 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 6

Smitha Ajay wrote:

...

I still havent figured how to get to the startup in the pocket pc and set a shortcut there.

  1. Open the File Explorer (Start -> programs -> File Explorer).
  2. Navigate to the folder where you have your program
  3. tap and hold on the EXE file.
  4. Choose Copy
  5. navigate to the /Windows/StartUp
  6. Tap and hold anywhere but not on any file (the "white space")
  7. choose "Paste Shortcut"
jv_getmore at 2007-8-30 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 7

You can create a shortcut prorammaticaly.

Create an empty file with extension "lnk" - For example: "myshortcut.lnk".

Write into file

21#"\myfolder\hello.exe"

if you want to create shortcut to "\myfolder\hello.exe". The number in the begining is a length of "\myfolder\hello.exe" (inkl. quotation marks)

Put it in startup directory - For example: "\Windows\AutoStart\"

TihomirIgnatov at 2007-8-30 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 8
Hi there,

You can create shortcuts in the startup folder by modifying the PPC or WCE .inf file in \obj\Debug\

scroll to the end of the file and add the following
[AddlShortcut]
"Pallas Foods",0,PallasFoods.exe

Go to the [DefaultInstall] and modify the following
CEShortcuts=Shortcuts
CopyFiles=Files.Common
CEShortcuts=AddlShortcut

then in [DestinationDirs] add the following
AddlShortcut=,%CE2%\Desktop

the above sample creates a shortcut on the desktop, you can change this to be the startup folder

or in code
Imports System.Runtime.InteropServices
<DllImport("coredll.dll")> _
Public Function SHCreateShortcut(ByVal szShortcut As String, ByVal szTarget As String) As Boolean
End Function
'Create a shortcut on the CE desktop
SHCreateShortcut("\Windows\Desktop\Explore.lnk", "\Windows\Explorer.exe")

Some

devices have lockdown features where you can enable a supervisor

password that will prevent the use from accessing the control panel

etc....

However if your device doesn't have such features i'd recommend locking down your application.

Things you can do from inside your application.
1. Disable the start menu and taskbar when the application starts. Also set the taskbar to hidden.
This will prevent users from gettin to the startmenu etc..

Imports System.Runtime.InteropServices

Public Class BarControl

<DllImport("coredll.dll", EntryPoint:="GetForegroundWindow", SetLastError:=True)> Private Shared Function GetForegroundWindow() As IntPtr
End Function

<DllImport("aygshell.dll", EntryPoint:="SHFullScreen", SetLastError:=True)> Private Shared Function SHFullScreen(ByVal hwndRequester As IntPtr, ByVal dwState As Integer) As Boolean
End Function

<DllImport("coredll.dll", EntryPoint:="EnableWindow")> Private Shared Function EnableWindow(ByVal hwnd As IntPtr, ByVal bEnable As Boolean) As Boolean
End Function

<DllImport("coredll.dll", EntryPoint:="FindWindow")> Private Shared Function FindWindow(ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
End Function

Private Const SHFS_SHOWSTARTICON As Integer = &H10
Private Const SHFS_HIDESTARTICON As Integer = &H20
Private Const SHFS_HIDESIPBUTTON As Integer = &H8
Private Const SHFS_SHOWSIPBUTTON As Integer = &H4
Private Const SHFS_SHOWTASKBAR As Integer = &H1
Private Const SHFS_HIDETASKBAR As Integer = &H2

Private Shared Function SetTaskBarEnabled(ByVal bEnabled As Boolean) As Boolean
Dim hwnd As IntPtr = FindWindow("HHTaskBar", Nothing)

If Not hwnd.Equals(IntPtr.Zero) Then
If bEnabled Then
Return EnableWindow(hwnd, True)
Else
Return EnableWindow(hwnd, False)
End If
End If
Return True
End Function

Private Shared Function SetTaskbarVisible(ByVal visible As Boolean) As Boolean
Dim hwnd As IntPtr = FindWindow("HHTaskBar", Nothing)

If Not hwnd.Equals(IntPtr.Zero) Then
If visible Then
Return SHFullScreen(hwnd, SHFS_SHOWTASKBAR)
Else
Return SHFullScreen(hwnd, SHFS_HIDETASKBAR)
End If
End If
End Function

Private Shared Function SetStartButtonVisible(ByVal visible As Boolean) As Boolean
Dim hwnd As IntPtr = GetForegroundWindow()

If Not hwnd.Equals(IntPtr.Zero) Then
If visible Then
Return SHFullScreen(hwnd, SHFS_SHOWSTARTICON)
Else
Return SHFullScreen(hwnd, SHFS_HIDESTARTICON)
End If
End If
End Function

Private Shared Function SetSIPVisible(ByVal visible As Boolean) As Boolean
Dim hwnd As IntPtr = GetForegroundWindow()

If Not hwnd.Equals(IntPtr.Zero) Then
If visible Then
Return SHFullScreen(hwnd, SHFS_HIDESIPBUTTON)
Else
Return SHFullScreen(hwnd, SHFS_HIDESIPBUTTON)
End If
End If
End Function

Public Shared Sub ShowTaskBar()
SetTaskBarEnabled(True)
SetTaskbarVisible(True)
End Sub

Public Shared Sub HideTaskBar()
SetTaskbarVisible(False)
SetTaskBarEnabled(False)
End Sub

Public Shared Sub ShowSIP()
SetSIPVisible(True)
End Sub

Public Shared Sub HideSIP()
SetSIPVisible(False)
End Sub

Public Shared Sub HideStartButton()
SetStartButtonVisible(False)
End Sub

Public Shared Sub ShowStartButton()
SetStartButtonVisible(True)
End Sub

End Class

2. Request a password in order to exit the application.

StriderIRL at 2007-8-30 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 9

This is exactly what i need . Does any one have the equivalent code in C#?

Thanks

Smitha

SmithaAjay at 2007-8-30 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 10

This is only a matter of few modifications :) If not sure you can use some of the vb.net to c# converter :)

http://www.developerfusion.co.uk/utilities/convertvbtocsharp.aspx

or for offline and other utilities: googleit...

jv_getmore at 2007-8-30 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...
# 11

Finally got to hide the start button with the below code :

Capture = true;

IntPtr hwnd = GetCapture();

Capture = false;

SHFullScreen(hwnd, SHFS_HIDESTARTICON);

However, the SIP Button is not getting hidden with the below code .Any ideas why?

//Hide Keyboard

Capture = true;

IntPtr hwnd2 = GetCapture();

Capture = false;

SHFullScreen(hwnd, SHFS_HIDESIPBUTTON);

I also tried using the 'SipShowIM(0)' following the below link to hide the SIP button but no luck either.

http://www.c-sharpcorner.com/Code/2002/May/SIPOnPocketPC.asp

Any ideas?

Thanks

Smitha

SmithaAjay at 2007-8-30 > top of Msdn Tech,Smart Device Development,.NET Compact Framework...