[APP][MORTSCRIPT] Windows (all): CD/DVD/BD/USB AutoRun Menu - Windows 8 Development and Hacking

Always was wondering how to run applications one can select from, hereby NOT using any 3rd party launchers as for example "Autorun CD Menu" and/or "Discstarter", etc.pp you have to pay for, if using Window's AUTORUN feature, which works with CD/DVD/BD/USB (USB only if follows U3-Standard) if not deactivated
[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Cdrom]
Autorun=dword:1
BTW: To enable AUTORUN on USB you have to change/create in Window's registry
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
NoDriveAutoRun=dword:91 (hex)
May be a similar registry key also exists as
[HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer]
If so, then you also have to change this key's value.
Click to expand...
Click to collapse
So I had the idea to realize such a launcher with wellknown "MortScript", the most fantastic scripting tool, IMHO. This launcher of course is not very visually appealing.
How it works:
The folders/files structure on the storage medium basically looks like
AUTORUN.INF
MORTSCRIPT.EXE
AUTORUNMENU.EXE
AUTORUNMENU.MSCR
PROGRAM FILES
DRIVERS
WINDOWS
Note that folder PROGRAM FILES has the 2 subfolders BASE and CUSTOM. BASE contains portable apps that never should be missing, as for example "Firefox Portable"; CUSTOM contains all the portable apps you intend to be present, too.
FYI: A huge collection of portable apps you find HERE.
Also note that each folder/subfolder has the 2 subfolders x86 and x84 where the appropriate portable app goes to. If only a x86 version is available, then it should be copied to x84, too.
Code:
\PROGRAM FILES
\BASE
\x86
\CommandPrompt
\<exefile>
\RegistryEditor
\<exefile>
\x64
\CommandPrompt
\<exefile>
\RegistryEditor
\<exefile>
\CUSTOM
\x86
\FileManager
\<exefile>
\x64
\FileManager
\<exefile>
Contents of file AUTORUN.INF looks as
[Autorun]
ShellExecute=AUTORUNMENU.EXE
UseAutoplay=1
The launcher script is coded as follows:
Code:
// © 2013 jwoegerbauer
// GPL v2
//
local()
title=systempath("ScriptName")
// determine path
pth=systempath("ScriptPath")
// determine drive
drive=pth
pos=find(drive,":")
if(pos)
drive=substr(drive,1,pos)
else
bigmessage("^NL^Couldn't determine drive letter.^NL^Exiting...","["&title&"] Error")
// quit
exit
endif
is64bit=direxists("C:\Windows\Boot\EFI")
// preset folder paths
pthwindows=pth\"Windows"
pthdrivers=pth\"Drivers"
pthbase=pth\"Program Files\Base"
pthcustom=pth\"Program Files\Custom"
// adjust paths according to Windows's Bit version
if(NOT is64bit)
pthcustom&="\x86"
pthbase&="\x86"
pthdrivers&="\x86"
pthwindows&="\x86"
title&=" (x86)"
else
pthcustom&="\x64"
pthbase&="\x64"
pthdrivers&="\x64"
pthwindows&="\x64"
title&=" (x64)"
endif
if(NOT direxists(pthcustom))
bigmessage("^NL^Folder^NL^"&pthcustom&"^NL^is missing.^NL^Exiting...","["&title&"] Error")
// quit
exit
endif
cntcustom=0
if(direxists(pthcustom))
foreach dir in directories(pthcustom\"*")
if(dir NE "")
cntcustom+=1
endif
endforeach
endif
cntbase=0
if(direxists(pthbase))
foreach dir in directories(pthbase\"*")
if(dir NE "")
cntbase+=1
endif
endforeach
endif
// create and populate array that holds custom applications' path
appscustom=array()
if(cntcustom)
idx=0
foreach dir in directories(pthcustom\"*")
if(dir NE "")
foreach exe in files(dir\"*.exe")
if(exe NE "")
idx+=1
appscustom[idx]=exe
endif
endforeach
endif
sleep(1)
endforeach
endif
// create and populate array that holds base applications' path
appsbase=array()
if(cntbase)
idx=0
foreach dir in directories(pthbase\"*")
if(dir NE "")
foreach exe in files(dir\"*.exe")
if(exe NE "")
idx+=1
appsbase[idx]=exe
endif
endforeach
endif
sleep(1)
endforeach
endif
optscustom=array()
if(elementcount(appscustom))
// populate options menu
idx=0
foreach exe in array(appscustom)
if(fileexists(exe))
idx+=1
optscustom[idx]=toupper(filebase(exe))
endif
sleep(1)
endforeach
endif
optsbase=array()
if(elementcount(appsbase))
// populate options menu
idx=0
foreach exe in array(appsbase)
if(fileexists(exe))
idx+=1
optsbase[idx]=toupper(filebase(exe))
endif
sleep(1)
endforeach
endif
if((NOT elementcount(optscustom))||(NOT elementcount(optsbase)))
bigmessage("^NL^Neither custom nor base apps found.^NL^Exiting...","["&title&"] Error")
// quit
exit
endif
if(elementcount(optscustom)&&elementcount(optsbase))
// display and loop a main menu until cancel button pressed
hint="Please select app's category ...^NL^"
optsmain=array("Custom","Basic")
idx=1
while(idx<>0)
idx=choice(title,hint,0,0,optsmain)
if(idx<>0)
// display and loop category related submenu
if(idx=1)
@appsmenu(appscustom,optscustom,title)
else
@appsmenu(appsbase,optsbase,title)
endif
endif
sleep(1)
endwhile
// done
exit
endif
if(elementcount(optscustom))
@appsMenu(appscustom,optscustom,title)
else
@appmenu(appsbase,optsbase,title)
endif
// done
exit
sub appsmenu(apps,opts,title)
local()
hint="Please select app be run ...^NL^"
idx=1
while(idx<>0)
idx=choice(title,hint,0,0,opts)
if(idx<>0)
// run the app selected
runwait(apps[idx])
endif
sleep(1)
endwhile
endsub
As you might have noticed, all you have to do is to supply the apps to be potentially run on the storage medium. The rest is done by the laucher script.
For your convenience I have packed the files AUTORUN.INF, MORTSCRIPT.EXE, AUTORUNMENU.EXE and AUTORUNMENU.MSCR into a ZIP-file which is attached to this post.
HTH

Related

copied exe-file is not a valid application

Hi,
I have written a litte application (eMbedded Visual C++) for Pocket PC 2002
to copy an exe-file from the root-directory to the startmenu-directory.
It seems to work fine, but when I start the copied application (the exe-file) I get the message
"... is not a valid Pocket PC application"
What is wrong with this applcation?
Or does anyone know how to call Copy from an Pocket PC application directly?
Here is the code:
// Setup.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#define SOURCEFILE_NAME "\\banking.exe"
#define DESTINATIONFILE_NAME "\\Windows\\Start Menu\\banking.exe"
#define DESTINATIONFILE_NAME_GERMAN "\\Windows\\Startmenü\\banking.exe"
int WINAPI WinMain( HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
// TODO: Place code here.
BOOL german = FALSE;
FILE *file = 0;
FILE *rfile = 0;
rfile = fopen (SOURCEFILE_NAME, "rb");
if (!rfile)
{
MessageBox (0, TEXT("Error"), TEXT("Setup"), MB_TOPMOST);
return 1;
}
file = fopen (DESTINATIONFILE_NAME_GERMAN, "wb");
if (!file)
file = fopen (DESTINATIONFILE_NAME, "wb");
else
german = TRUE;
if (file)
{
char buffer [1000];
size_t num_read = 0;
size_t num_written = 0;
size_t num_read_tot = 0;
size_t num_written_tot = 0;
do
{
num_read = fread (buffer, sizeof (char), 1000, rfile);
if (feof(rfile))
break;
num_read_tot += num_read;
if (num_read > 0)
{
num_written= fwrite (buffer, sizeof (char), num_read, file);
num_written_tot += num_written;
}
else
break;
} while (1);
fclose (file);
}
fclose (rfile);
DWORD attr = 0;
BOOL rc = 0;
attr = GetFileAttributes (TEXT(SOURCEFILE_NAME));
if (german)
rc = SetFileAttributes (TEXT(DESTINATIONFILE_NAME_GERMAN), attr);
else
rc = SetFileAttributes (TEXT(DESTINATIONFILE_NAME), attr);
MessageBox (0, TEXT("Ready"), TEXT("Setup"), MB_TOPMOST);
return 0;
}
// END
Hello,
You are trying to reinvent the wheel by copying yourself the info from the file. Use the CopyFile function.
But your error
"... is not a valid Pocket PC application"
Click to expand...
Click to collapse
has probably appeared for another reason...
You should also look at SHFileOperation
It's not a good idea to copy *.exe files to start menu...
Create a shortcut with CECreateShortcut(...) instead.
If this is part of a application setup (in a cab file) just create the shortcut with the build in features:
...
[DefaultInstall]
...
CEShortcuts = Shortcuts
...
[Shortcuts]
BankingMenuText,0,banking.exe
...
John
John,
thank you for your comment.
Perhaps you ore someone else can tell me how to create a shortcut (for the banking.exe) from a Pocket PC - application ?
(The background is as follows:
I want to deliver my banking-application on SD-Card;
a little setup-application on the SD-Card copies the banking.exe from SD-Card into the program-directory of the Pocket PC.
And last but not least this setup-application shoult insert a shortcut for the copied banking.exe in the Start Menu.
OK,
cabwiz.exe does exactly the job.
One open question:
How can I achieve, that after executing the cab-file is N O T deleted?
Create Shortcut with SHCreateShortcut.
Not deleting cab file : mark it as read-only on the desktop (before copying) 8)

MortScript examples accumulation

Hi there,
since I realized MortScript finally got to some use here, too, and I'm currently building an updated site, I wanted to gather some scripts which I could offer as examples on my page. Of course with a link to any origin you want - that way the author gets the credits, and I don't need to keep up with the latest update all the time...
Since I lost track of all the threads and scripts, I'd be nice if you could send me the interesting topics (a reply might be useful for others, too, but PM or contact formular or forum on mort.sto-helit.de is fine, too...).
TIA,
Mort
The 'clicky' thing:
Code:
if question "Please set the Camera app to photo mode before executing this script. Additionally, please remember to disable <<Reviev After Capture>> option in Camera before running this script! Run the script?","Important note"
setbacklight 1,1
Input limit, 1, "Total images to capture","MultiCapture"
if equals "",%limit%
set limit,10
endif
set total,0
Input delayer, 1, "Capture interval (seconds)","MultiCapture"
set delayer,%delayer%*1000
if equals %delayer%,0
set delayer,1000
endif
%czas%=%delayer%*%limit%/1000
%czas_m%=%czas%/60
%czas%="Total capture time: "&%czas%&" seconds, this is "&%czas_m%&" minutes."
message %czas%,"MultiCapture"
if question "Lock the touchscreen?","Touchscreen lock"
run tpdisable.exe
endif
run camera.exe
WaitForActive "Camera",10
setbacklight 0,0
while wndActive "Camera"
SendCR "Camera"
sleep %delayer%
%total%=%total%+1
if equals %total%,%limit%
Close "Camera"
endif
endwhile
run tpenable.exe
%total%="Images captured: " & %total%
message %total%,"Done"
endif
It does some pictures at regular interval, locking screen (using TPEnable/TPDisable).
The other script:
Code:
if wndActive "Camera"
regReadDword HKCU,"Software","tplock",lok
if equals %lok%,1
run "\windows\tpenable.exe"
regWriteDword HKCU,"Software","tplock",0
message "Screen unlocked.","Device lock"
else
run "\windows\tpdisable.exe"
regWriteDword HKCU,"Software","tplock",1
endif
else
run "\windows\alttab.exe"
endif
I have it bound to 'Record' button on my BA. If the camera is active, it locks the touchscreen (TPEnable/Disable again). If not - it executes SPBPocketPlus's AltTab.
MortScript rulez
I have one more, but a buggy one - it updates the Camera image capture dir to dd_mm_yyy. Will post it later on today...
Code:
if not regKeyExists HKCU,"Software\IA Style\IA CameraWizard(Pocket PC)\2.21\Strings","xImage folder"
regReadString HKCU,"Software\IA Style\IA CameraWizard(Pocket PC)\2.21\Strings","Image folder",pth
%msg%="This is the first time you use this script. The current image store path is: "&%pth%
message %msg%
if question "Run the Camera to change this value?"
runwait "camera.exe"
endif
regReadString HKCU,"Software\IA Style\IA CameraWizard(Pocket PC)\2.21\Strings","Image folder",pth
RegWriteString HKCU,"Software\IA Style\IA CameraWizard(Pocket PC)\2.21\Strings","xImage folder",%pth%
if question "Update the capture dir now?"
regReadString HKCU,"Software\IA Style\IA CameraWizard(Pocket PC)\2.21\Strings","Image folder",pth
else
exit
endif
endif
GetTime dat, "Y_m_d"
regReadString HKCU,"Software\IA Style\IA CameraWizard(Pocket PC)\2.21\Strings","xImage folder",pth
%dat%=%pth%&"\"&%dat%
MkDir %dat%
RegWriteString HKCU,"Software\IA Style\IA CameraWizard(Pocket PC)\2.21\Strings","Image folder",%dat%
%dat%="Image capture folder updated to "&%dat%
SleepMessage 5,%dat%,"Capture folder updated",1
Here is a short & sweet script I wrote that asks you if you'd like to rotate your screen before running TomTom then rotates it back when TomTom exits. This is useful because when driving, TomTom looks better in landscape mode, but there are times when just walking around and stuff it's better in portrait mode.
No credit needed really because of it's simplicity.
Edit: Sorry, I deleted the file off my server a while back when I was doing some spring cleaning... I don't have a copy of it any where.
Really it was just a couple mortscript commands. Anyone who spends 5 minutes and reads the mortscript documentation can figure it out.
BTW, I LOVE mortscript. It's very handy and I see it becoming more useful as the needs arise.
BT Sync
Hi,
I couldn't live without it. The following script connects Bluetooth through ActiveSync and Syncs. The connection will remain active until the script is started again, or the connection is closed manually.
Code:
If NOT wndExists "Connected to MEDIACENTER"
RegReadDWord HKLM, System\State\Hardware, Bluetooth, Bluetooth
If Expression %Bluetooth% <= 8
Set BluetoothWas, "Off"
Run "\Windows\ToggleBTH.exe"
Sleep 3000
EndIf
Run "\Windows\rnaapp.exe", -n -m -e"MEDIACENTER"
WaitFor "Connected to MEDIACENTER", 15
Run "\Windows\udp2tcp.exe"
Run "\Windows\rapiclnt.exe", -dppp_peer
Run "\Windows\repllog.exe", /remote /sched /h
Sleep 1000
RegWriteDWord HKLM, System\State\Hardware, Cradled, 1
While wndExists "Connected to MEDIACENTER"
Sleep 1000
EndWhile
Run "\Program Files\MortScript\TKill.exe", UDP to TCP proxy
Run "\Program Files\MortScript\TKill.exe", Remote API Client
Run "\Program Files\MortScript\TKill.exe", ActiveSync
If equals %BluetoothWas%, "Off"
Run "\Windows\ToggleBTH.exe"
EndIf
Else
Run "\Program Files\MortScript\TKill.exe", Connected to MEDIACENTER
EndIf
Needless to say you need to replace MEDIACENTER with the name of your own BT Connection.
ToggleBTH turns on the BlueTooth radio if it wasn't already on, and turns it off again is the connection is dropped.
TKill really kills the various processes when done; killing them with MortScript's internal commands didn't seem stable.
Cheers,
Cacti
GPRS Sync
Code:
# Witch operator are we on?
RegReadString HKLM, System\State\Phone, Current Operator Name, Operator
If Equals %Operator%, "Orange"
Set Orange, "On"
EndIf
# Orange Active? Switch to T-Mobile.
If Equals %Operator%, "Orange"
Run "\Windows\STK.exe"
SendUp STK Service
SendUp STK Service
SendDown STK Service
SendCR STK Service
Sleep 500
Minimize STK Service
EndIf
# Is T-Mobile Active?
RegReadString HKLM, System\State\Phone, Current Operator Name, Operator
While Not Equals %Operator%, "T-Mobile NL"
Sleep 1000
RegReadString HKLM, System\State\Phone, Current Operator Name, Operator
EndWhile
# GPRS Notificatie opslaan en daar uitzetten
RegReadDWord HKCU, ControlPanel\Notifications\{8ddf46e7-56ed-4750-9e58-afc6ce486d03}, Options, GPRSConnectNotification
RegWriteDWord HKCU, ControlPanel\Notifications\{8ddf46e7-56ed-4750-9e58-afc6ce486d03}, Options, 0
#Activesync
If wndExists "ActivSync"
Set ActiveSync, "On"
EndIf
Run "\Windows\repllog.exe", /h /sched /remote
Sleep 500
MouseClick ActiveSync 20, 310
Sleep 500
Minimize ActiveSync
RegReadDWord HKCU, Software\Microsoft\ActiveSync\Partners\{4FF3ACFA-3E07-42E1-83D9-4F04714CDC0B}, LastSyncSuccess, LastSyncSuccess
RegReadDWord HKCU, Software\Microsoft\ActiveSync\Partners\{4FF3ACFA-3E07-42E1-83D9-4F04714CDC0B}, LastSyncSuccess, NewSyncSuccess
While Equals %NewSyncSuccess%, %LastSyncSuccess%
Sleep 1000
RegReadDWord HKCU, Software\Microsoft\ActiveSync\Partners\{4FF3ACFA-3E07-42E1-83D9-4F04714CDC0B}, LastSyncSuccess, NewSyncSuccess
EndWhile
RegWriteDWord HKCU, ControlPanel\Notifications\{8ddf46e7-56ed-4750-9e58-afc6ce486d03}, Options, %GPRSConnectNotification%
If not Equals %ActiveSync%, "On"
Run "\Program Files\MortScript\TKill.exe", ActiveSync
EndIf
If Equals %Orange%, "On"
Run "\Windows\STK.exe"
SendUp STK Service
SendUp STK Service
SendCR STK Service
Sleep 1000
Minimize STK Service
Minimize STK Service
EndIf
This script ActiveSyncs over GPRS. I use a Dual SIM, (Orange & T-Mobile) and only the T-Mobile subscription have GPRS. So the script first determines if T-Mobile is active. If not is switches SIM. After that it just starts ActiveSync and syncs the {4FF3ACFA-3E07-42E1-83D9-4F04714CDC0B} partnership. After it finishes is swichtes SIMs again; I'm mainly on the Orange SIM.
I use the same methode before starting TomTom so my traffic information can be downloaded while driving.
If someone is interested I also have a script that (allong with some other little proggies) starts TomTom automaticly when I connect the power connector, but only if my carkit is connected.
MortScript makes me very lazy
Cheers,
Cacti
Code:
RegWriteString HKLM,Drivers\active\73,Name,COM6:
if question "Enable BT/GPS before running OziExplorer?","OziExplorer"
run "\program files\vijay555\vjvolubilis\vjvolubilis.exe", -blueon
runwait "\storage card2\oziexplorer\oziexplorerce.exe"
run "\program files\vijay555\vjvolubilis\vjvolubilis.exe", -blueoff
else
if question "Run OziExplorer anyway?","OziExplorer"
run "\storage card2\oziexplorer\oziexplorerce.exe"
endif
endif
Yay, does anyone use OziExplorerCE? I sometimes do
The script above utilizes vijay's VJVolubilis (great app, imho) to enable Bluetooth. It also adds 'fake' COM port in order to allow proper OziExplorerCE GPS configuration.
this is a very informative and useful thread.
i use mortscript on my T-Mobile SDA smartphone.
Alarm Script (reminder):
Cleanup Recently Used Programs
This script removes the list of recently used programs in the Start Menu.
Code:
if question ("Do you want to cleanup the Recent Programs from your Start Menu?","oldSAP's Cleanup")
x=0
While NOT (x = 12)
RegWriteString ("HKCU","Software\Microsoft\Shell\TaskSwitch",%x%,"")
x=x+1
EndWhile
if question ("You need to restart your device to see the effect. Restart Now?","oldSAP's Cleenup")
Reset
EndIf
EndIf
Copy/Paste
Copy and Paste script
Code:
num=Input ( "1=Copy All 2=Copy Word(s) 3=Copy Line 4=Paste ", "oldSAP Copy/Paste",1 )
if equals %num%, "1"
SendCtrlKey A
SendCtrlKey C
Else
if equals %num%, "2"
x=Input("How many words do you want to copy?","no. of words",1)
Repeat %x%
SendRight( "", 1, 1 )
EndRepeat
SendCtrlKey C
Else
if equals %num%, "3"
SendEnd( "", 0, 1 )
SendCtrlKey C
Else
if equals %num%, "4"
SendCtrlKey V
Else
EndIf
Wow, you sure give me some work for the weekend...
Very interesting collection, thank you!
I have a collection of scripts at this link.
http://discussion.treocentral.com/showthread.php?t=132525
Yay, I see LEDUp in use
(gotta switch to MortScript 4, 3.5 seems to be a bit old... )
here is a very basic script, I use it for apps that I want to stay alive until I close the app, eg GPS software, in particular Destinator.
Note, for some reason the volume part doesnt seem to work as it should.
Code:
#Basic script to set no timeouts and full brightness while using Destinator
#Read registry settings
#volume is not working for some reason
#Volume = RegRead ("HKCU", "ControlPanel\Volume\","Volume")
BattSuspendTimeout = RegRead ("HKLM", "System\CurrentControlSet\Control\Power\Timeouts","BattSuspendTimeout")
ACSuspendTimeout = RegRead ("HKLM", "System\CurrentControlSet\Control\Power\Timeouts","ACSuspendTimeout")
BatteryTimeout = RegRead ("HKCU", "ControlPanel\Backlight", "BatteryTimeout")
ACTimeout = RegRead ("HKCU", "ControlPanel\Backlight", "ACTimeout")
Brightness = RegRead ("HKCU", "ControlPanel\Backlight", "Brightness")
ACBrightness = RegRead ("HKCU", "ControlPanel\Backlight", "ACBrightness")
#Set registry settings
#RegWriteDword ("HKCU", "ControlPanel\Volume\","Volume", 2576980377)
RegWriteDword ("HKLM", "System\CurrentControlSet\Control\Power\Timeouts","BattSuspendTimeout",0)
RegWriteDword ("HKLM", "System\CurrentControlSet\Control\Power\Timeouts","ACSuspendTimeout",0)
RegWriteDword ("HKCU", "ControlPanel\Backlight", "BatteryTimeout", 0)
RegWriteDword ("HKCU", "ControlPanel\Backlight", "ACTimeout", 0)
RegWriteDword ("HKCU", "ControlPanel\Backlight", "Brightness", 10)
RegWriteDword ("HKCU", "ControlPanel\Backlight", "ACBrightness", 10)
#Change application to run here
RunWait ("\DestinatorApps\Destinator\DestiRobot.exe")
#Set registry settings back to normal use mode
#RegWriteDword ("HKCU", "ControlPanel\Volume\","Volume", Volume)
RegWriteDword ("HKLM", "System\CurrentControlSet\Control\Power\Timeouts","BattSuspendTimeout",BattSuspendTimeout)
RegWriteDword ("HKLM", "System\CurrentControlSet\Control\Power\Timeouts","ACSuspendTimeout",ACSuspendTimeout)
RegWriteDword ("HKCU", "ControlPanel\Backlight", "BatteryTimeout", BatteryTimeout)
RegWriteDword ("HKCU", "ControlPanel\Backlight", "ACTimeout", ACTimeout)
RegWriteDword ("HKCU", "ControlPanel\Backlight", "Brightness", Brightness)
RegWriteDword ("HKCU", "ControlPanel\Backlight", "ACBrightness", ACBrightness)
Great to see such a collection of genius in just ONE post!
It is probably a good idea to inform our captive audience that a majority of these scripts will work only with Mort's 4.0 RC3 version (or at least not the 3.1 version) so if you are having some problems launching these wonderful scripts download the Release Candidtate:
h++p://www.sto-helit.de/downloads/pocketpc/MortScript-4.0RC3.zip
(hope you don't mind me posting the link Mort)...
"Live long and Script!"
There's RC5 around at the "site to come": http://mort.sto-helit.de (see http://www.sto-helit.de for why there are two sites... ). It's mostly bugfixes. In RC4 I added the possibility to access COM ports, but I still have to update the manual... On that site, you'll also soon be able to find the scripts posted here...
There's also a new beta of MortButtons and the MortButton skins are migrated. But there's still a lot to do, esp. regarding MortPlayer...
Mort,
I noticed their is RC7 now, what has changed since RC4.. Is there a changelog we can view?
Need some help with the BT sound.
I got the bellow mortscript (posted by senergy) on my phone. And when I click on it it runs. But when I try to listen to sound over bluetooth it still goes directly to voicecommand regardless if I click yes or no. Am I doing something wrong? (using mortscript version 4)
EDIT:
Figured out the problem and removed bad script (Was using another cut and paste, this one did work!)
Orginaly posted by senergy
#basic mortscript to enable bt sound
#question
Switch (question ( "Do you want BT sound?", "Question", "YesNo"))
case (1)
RegWriteDword ("HKLM","Software\OEM\VoiceCommand","LaunchApEnable",0)
RegWriteDword ("HKLM","Software\OEM\VoiceCommand","VoiceCmdDuration",86400)
case (0)
RegWriteDword ("HKLM","Software\OEM\VoiceCommand","LaunchApEnable",1)
RegWriteDword ("HKLM","Software\OEM\VoiceCommand","VoiceCmdDuration",30)
endSwitch
Mortscript Press Button
Can someone please help me with this script, it should (amongst others) press Warning Message key in Navigon Mobile Navigator 6 but it doesn't always.
Probably because startuptime varies? I'm not sure about remaining script either......
# Position of MN6 Button to press
Set Position_X, "170"
Set Position_Y, "290"
# Set Bluetooth On
run "\Program Files\vijay555\VJVolubilis\VJVolubilis.exe", -blueon
# Start Navigon including FlitsNav
Run "\My Documents\POIWarner\FlitsNav.exe"
WaitForActive "Mobile Navigator 6", 60000
GetColorAt %Position_X%, %Position_Y%, colorStart
# Waiting time in milliseconds
Sleep 35000
Set true, "1"
While equals %true%, "1"
Sleep 1000
GetColorAt %Position_X%, %Position_Y%, color
If not equals %color%, %colorStart%
If wndActive "Mobile Navigator 6"
Sleep 1000
MouseClick "Mobile Navigator 6", %Position_X%, %Position_Y%
EndIf
Set true, "0"
EndIf
EndWhile
# Kills FlitsNav and Bluetooth after exit MN6
Runwait ("\SDMMC\MN6\MN6.exe")
run "\Program Files\vijay555\VJTaskKiller\VJTaskKiller.exe", FlitsNav
run "\Program Files\vijay555\VJVolubilis\VJVolubilis.exe", -blueoff
MortScript
Here`s some of my stuff, unfortunately mostly still on the "old" syntax.
I´ve started to rebuff some of the scripts (new syntax, mostly new concepts) but ran out of time during the last month.
I try to create "modules" for recurring tasks, to be called from within other scripts or, if appliccable, to be capable run standalone as well. Most of the module expect variables to be set, hence must be called using callscript.
Here is a newer one to display status messages and a kind of countdown. Once kicked off it runs on its own, refreshes (if required, i.e. if the status display needs to change) every second displaying the content of the registry value "info" until the registry value "DoShow" toggles. During the process a given startvalue (approximated duration) is decreased like a countdown and restartet if necessary.
This one is started with run, to have it operate totally independent, hence content is communicated via registry values.
Code:
# Modul zum Zeigen von Status / Info messages
# uebergeben per Reg. Werten
#
# HGH 11-26/06
#
errorlevel warn
#
if ( \
NOT \
( \
RegValueExists \
("HKCU", "Software\Mistrix\ShowStat","DoShow") \
AND \
RegValueExists \
("HKCU", "Software\Mistrix\ShowStat","RefCycle") \
AND \
RegValueExists \
("HKCU", "Software\Mistrix\ShowStat","Info") \
AND \
RegValueExists \
("HKCU","Software\Mistrix\ShowStat","InfoHeader") \
AND \
RegValueExists \
("HKCU", "Software\Mistrix\ShowStat", "OKAllow") \
) \
)
message ( \
"RegWerte nicht gefunden", \
SystemPath("ScriptName") \
& SystemPath("ScriptExt") \
)
exit
EndIf
#
# "Gesamtzeit" aus Reg lesen
GCycle = RegRead ("HKCU", "Software\Mistrix\ShowStat", \
"RefCycle")
#
TStampStart = TimeStamp ()
#
while (RegRead ("HKCU", "Software\Mistrix\ShowStat", \
"DoShow") = 1)
InfAlt = RegRead ("HKCU", "Software\Mistrix\ShowStat", \
"Info")
If (TimeStamp () - TStampStart > GCycle )
TStampStart = TimeStamp ()
EndIf
ShowCycle = GCycle - TimeStamp () + TStampStart
Sleepmessage \
( \
ShowCycle , \
InfAlt, \
RegRead ("HKCU", "Software\Mistrix\ShowStat", \
"InfoHeader"), \
1, \
RegRead ("HKCU", "Software\Mistrix\ShowStat", \
"DoShow") <> 1 OR InfAlt ne RegRead \
("HKCU", "Software\Mistrix\ShowStat", \
"Info") \
)
#
# ggf. (OKAllow=1) warten,
# bis sich ein Status geaendert hat
while ( \
RegRead ("HKCU", "Software\Mistrix\ShowStat", \
"DoShow") = 1 AND InfAlt eq RegRead \
("HKCU", "Software\Mistrix\ShowStat", \
"Info") AND RegRead ("HKCU", \
"Software\Mistrix\ShowStat", \
"OKAllow") = 1 \
)
sleep (1000)
EndWhile
#
EndWhile
#
exit
Next is an example, how to use it. There could be any
code instead of the sleeps,
just reload "Info" whenever you want to have your
status display updated...
Code:
# TestRahmen fuer Status / Info messages
# mittels ShowStat.mscr
#
# HGH 11-26/06
#
errorlevel warn
#
# Setzen der Reg. Werte - set the registry values
# Stausmeldungen aktiv - activate status display
RegWriteDword ("HKCU", "Software\Mistrix\ShowStat", \
"DoShow", 1)
# Darf der User Message wegcklicken? -
# may the user cancel status display
RegWriteDword ("HKCU", "Software\Mistrix\ShowStat", \
"OKAllow", 1)
# "Gesamtzeit" - approximated total time
RegWriteDword ("HKCU", "Software\Mistrix\ShowStat", \
"RefCycle", 30)
# InfoHeader - title
RegWriteString ("HKCU", "Software\Mistrix\ShowStat", \
"InfoHeader", "TestStati" )
# InfoText - status text
RegWriteString ("HKCU", "Software\Mistrix\ShowStat", \
"Info", "Status1" )
#
# Starten der Show Info Routine - status modul start
run ( SystemPath("ScriptPath") \ "ShowStat.mscr")
#
sleep (8000)
#
# neuer Infotext - new status content
RegWriteString ("HKCU", "Software\Mistrix\ShowStat", \
"Info", "Status2" )
#
sleep (12000)
#
# neuer Infotext - new status content
RegWriteString ("HKCU", "Software\Mistrix\ShowStat", \
"Info", "Status3" )
#
sleep (5000)
#
# Statusmeldungen inaktiv - status display off
RegWriteDword ("HKCU", "Software\Mistrix\ShowStat", \
"DoShow", 0)
#
exit

How do i get folder size rapidly?!

I write a C# app for WindowsMobile.
in order to get a nonrecursive folder size i have this routine:
Code:
static long GetDirectorySize(String path)
{
long size = 0;
String []files = Directory.GetFiles(path);
foreach (String f in files)
{
FileInfo fi = new FileInfo(f);
size += fi.Length;
}
return size;
}
now, my directory (in Storage Card) has about 1000 files that has about 4MB of data alltogether.
the GetDirectorySize takes forever to execute (60 seconds or so) and provide a horribole user expericnce.
executing this in a thread does not help either - i need the response as fast as possibole.
I was wondering if someone could help me figure out how to get folder size (nonrecursive) more rapidly.
in general, i also want to find the older file in the directory and delete it (kid of cache operation). how do i do that without waiting forever to complete?
storing an index file might not be what i'm looking for.
Thanks
I don't know about C#, but in C++ I use GetDiskFreeSpaceEx function, see HERE.
PS,
I think this goes in the Q&A forum?
dgaud007 said:
I use GetDiskFreeSpaceEx function
Click to expand...
Click to collapse
This does not help with Folder size.
My intention is to manage Cache folder and monitor its size and clear out some cached files in case the cache size of the folder is too big.
getting the disk size is not the way to deal with folder size
You can use it for individual folders, as the folder name is the 1st input parameter. I've used at least for \My Documents which is a regular folder and it works. Here is an excerpt from MSDN:
lpDirectoryName [in, optional]
A directory on the disk.
If this parameter is NULL, the function uses the root of the current disk.
If this parameter is a UNC name, it must include a trailing backslash, for example, "\\MyServer\MyShare\".
This parameter does not have to specify the root directory on a disk. The function accepts any directory on a disk.
The calling application must have FILE_LIST_DIRECTORY access rights for this directory.
Click to expand...
Click to collapse
As per MSDN, here is how you implement it in C#:
Code:
[DllImport("kernel32.dll", CharSet=CharSet.Auto, SetLastError=true)]
internal static extern bool GetDiskFreeSpaceEx(string drive, out long freeBytesForUser, out long totalBytes, out long freeBytes);
I tested GetDiskFreeSpaceEx.
- The coredll has to be used instead kernel32dll (for WindowsMobile).
- the TotalBytes returns the SD card size (on which the folder exists)
- the freeBytesForUser equals FreeBytes and returns the free space in the SD card
this does return the folder size.
appreciate further help.
thanks
I double checked and you're right. Looks like you'll have to recurse while adding the individual sizes. I couldn't find an easier method in a brief search in google. Sorry about the confusion!
PS,
checkout this app...
I'm not that much of a C# expert but isn't the 1000 times calling "new" slowing down? I'd try to write a traditional C++ application using simple FindFirstFile and FindNextFile functions and compare speed towards the C# application. If it's faster then you can just build a C++ DLL and PInvoke her. I'm not sure if results are better but at least it's worth a try.
solution found
I managed to resolve this and get a speedy result by replacing with this code.
all the best.
Code:
private static long GetDirectorySize(String path)
{
long size = 0;
[COLOR="DarkGreen"] /* Slow code
String []files = Directory.GetFiles(path);
foreach (String f in files)
{
FileInfo fi = new FileInfo(f);
size += fi.Length;
} */[/COLOR]
DirectoryInfo di = new DirectoryInfo(path);
FileInfo []fi = di.GetFiles();
for (int i = 0; i < fi.Length; i++)
size += fi.Length;
return size;
}
btw: get my app at http://www.logelog.com/utils

Adding context-menu extensions in File Explorer

I am trying to add an extension to the context menu of the File Explorer. I know how to do this in desktop windows, but it doesn't work in Windows Mobile. This is what it looks like for destktop windows:
Code:
RegistryKey key = Registry.ClassesRoot.CreateSubKey("*");
RegistryKey shellKey = key.CreateSubKey("Shell");
RegistryKey emacsKey = shellKey.CreateSubKey("emacs");
emacsKey.SetValue(null, "Edit with emacs");
RegistryKey commandKey = emacsKey.CreateSubKey("Command");
commandKey.SetValue(null, "c:\\emacs\\bin\\emacs.exe %1");
I tried the same thing on WM6.5.3, only I switched the call to emacs for "pword.exe %1". No additional items showed up in my context menu. I decided to ditch the "*" and try to add a context menu for a specific file type first. My next attempt looked like this:
Code:
RegistryKey extensionKey = Registry.ClassesRoot.CreateSubKey(".csv");
extensionKey.SetValue(null, "csvfile");
RegistryKey csvfileKey = Registry.ClassesRoot.CreateSubKey("csvfile");
RegistryKey shellKey = csvfileKey.CreateSubKey("Shell");
RegistryKey openKey = shellKey.CreateSubKey("Open");
RegistryKey commandKey = editKey.CreateSubKey("Command");
commandKey.SetValue(null, "pword.exe %1");
RegistryKey editKey = shellKey.CreateSubKey("EditFile");
editKey.SetValue(null, "Edit This File");
RegistryKey commandKey = editKey.CreateSubKey("Command");
commandKey.SetValue(null, "pword.exe %1");
Which creates an (abbreviated) registry tree like this:
Code:
[-] HKEY_CLASSES_ROOT
[-] .csv = csvfile
[-] csvfile
[-] Shell
[-] Open
[-] Command = "pword.exe %1"
[-] EditFile = "Edit This File"
[-] Command = "pword.exe %1"
My "Edit This File" option still does not show up in the context menu when I right click on a .csv file, but if I left click on it, it opens up in Pocket Word, as expected.
There must be some way to do this. I just don't know why it can't match the way it works in desktop windows. I guess I have two questions:
1. Is it possible to add context-menu items in File Explorer through the registry?
2. If so, can I extend it to files of all types? ( "*" )
I am using C# right now, but if there is an easier solution in C/C++ I'm open to it. Thanks in advance for any tips.
I'm trying the same thing and I also have no solution for this.
But i found a code sample from Microsoft, it's called CTXMenu and is included in the Windows Mobile 6.5.3 DTK.
It demonstrates how to implement a context menu extension handler.
The application extends the File Explorer context menu that appears when you tap and hold a file.
Unfortunately it's coded in C++ and I'm not so familiar with C++, so I can't help you with your problem.
But if this code sample is useful for you, I would appreciate it if you could tell me how you managed it to get this work.
I had similar problem these days. After about 2 days of googleing and editing and trying (with my minimal c++ knowledge) I succeded to create menu item which started my application with filename parameter. Of course I used the CTXMenu example and some other examples too.
As far as I know (and tried) there is not other way than extension to file manager.
Good thing is you can create menu item for all filles ("*").

[Q] detecting .net version [vb.net]

basically what the title says. I've written some code tht should detect the .net version and if it is not 3.5 or newer then show a message box and then exit the program but it's giving me a nullreferrence exception becuase of the way it checks for the version number. I'll post it below and bold the line that gives the error.
Code:
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Const[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] NetCFKey [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"software\Microsoft\.netcompactframework\"[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] NetCFPath [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] RegistryKey = Registry.LocalMachine.OpenSubKey(NetCFKey)[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] NetCFValueNames() [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = NetCFPath.GetValueNames[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]For[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Each[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] valuename [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]In[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] NetCFValueNames[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] NetCFValue [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] RegistryKey = NetCFPath.OpenSubKey(valuename)[/SIZE]
[B][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] value [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Object[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = NetCFValue.GetValue([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"3.5.9085.00"[/COLOR][/SIZE][/COLOR][/SIZE][/B][SIZE=2][B])[/B][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] value [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Is[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"0"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] MsgBoxQ [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]".Net Compact Framework 3.5 or greater is not installed."[/COLOR][/SIZE][/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Caption [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]String[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] = [/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"Error"[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] Buttons [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] MessageBoxButtons = MessageBoxButtons.OK[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] MsgBoxIcon [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] MessageBoxIcon = MessageBoxIcon.Exclamation[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] OKBox [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] DialogResult[/SIZE]
[SIZE=2]OKBox = MessageBox.Show(MsgBoxQ, Caption, Buttons,_[/SIZE]
[SIZE=2] MsgBoxIcon, MessageBoxDefaultButton.Button1)[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] OKBox = Windows.Forms.DialogResult.OK [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2]Application.Exit()[/SIZE]
[SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]ElseIf[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] value [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Is[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2] ([/SIZE][SIZE=2][COLOR=#a31515][SIZE=2][COLOR=#a31515]"1"[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2]) [/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[/COLOR][/SIZE][SIZE=2][COLOR=#0000ff][SIZE=2][COLOR=#0000ff]Next[/COLOR][/SIZE]
[/COLOR][/SIZE]
My first thought was to use a wildcard so the keyname would look like this:
"3.5.*"
but after doing a little googling i'm not sure it will work. So Does anybody have any ideas on how to improve it?
Thanks guys.
AFAIK each WinCE/WinMo device has a file ceconfig.h in <root>\Windows. Why not simply read this file to get out the .NET CF version installed. if any? In one of my private projects to be run on a WinCE 5.0 based device I realised this with MortScript (Basic alike synthax) as following (excerpt):
Code:
#Read CeConfig.h (CE license level)
Local(windows_ceconfig_file,file,line,cnt,netcf20,netcf35)
netcf20=0
netcf35=0
windows_ceconfig_file="\Windows\ceconfig.h"
cnt=0
If(FileExists(windows_ceconfig_file))
file=""&ReadFile(windows_ceconfig_file,FileSize(windows_ceconfig_file,MB))
If(Length(file))
file=Split(file,"^NL^")
ForEach line in Array(file)
cnt+=1
If((NOT netcf20)||(NOT netcf35))
If(Find(line,"NETCFV2_MODULES_DOTNETV2"))
netcf20=1
ElseIf(Find(line,"NETCFV35_MODULES_DOTNETV35"))
netcf35=1
EndIf
EndIf
#stop further searching
If(netcf20||netcf35)
Break
EndIf
Sleep 100
EndForEach
EndIf
Clear(file)
Clear(line)
EndIf
Clear(windows_ceconfig_file)
If(NOT cnt)
#Error processing goes here
EndIf
Clear(cnt)
Please apologize this contribution! Should only be a demonstration it could be done another way.
jwoegerbauer said:
AFAIK each WinCE/WinMo device has a file ceconfig.h in <root>\Windows. Why not simply read this file to get out the .NET CF version installed. if any? In one of my private projects to be run on a WinCE 5.0 based device I realised this with MortScript (Basic alike synthax) as following (excerpt):
Code:
#Read CeConfig.h (CE license level)
Local(windows_ceconfig_file,file,line,cnt,netcf20,netcf35)
netcf20=0
netcf35=0
windows_ceconfig_file="\Windows\ceconfig.h"
cnt=0
If(FileExists(windows_ceconfig_file))
file=""&ReadFile(windows_ceconfig_file,FileSize(windows_ceconfig_file,MB))
If(Length(file))
file=Split(file,"^NL^")
ForEach line in Array(file)
cnt+=1
If((NOT netcf20)||(NOT netcf35))
If(Find(line,"NETCFV2_MODULES_DOTNETV2"))
netcf20=1
ElseIf(Find(line,"NETCFV35_MODULES_DOTNETV35"))
netcf35=1
EndIf
EndIf
#stop further searching
If(netcf20||netcf35)
Break
EndIf
Sleep 100
EndForEach
EndIf
Clear(file)
Clear(line)
EndIf
Clear(windows_ceconfig_file)
If(NOT cnt)
#Error processing goes here
EndIf
Clear(cnt)
Please apologize this contribution! Should only be a demonstration it could be done another way.
Click to expand...
Click to collapse
I'll check this method out. Thanks a lot.
The reason i did it the way i did was because every device has a registry value in HKLM\software\microsoft\.netcompactframework that is named the same as the build number and MS recommends checking for those values.
Something else to think about :-
If your application is already written in .NET CF 3.5, it is probably going to throw an error anyway if version 3.5 is not present on the device.
This will happen as the program is loaded, before your VB validating code even gets a chance to run.
stephj said:
Something else to think about :-
If your application is already written in .NET CF 3.5, it is probably going to throw an error anyway if version 3.5 is not present on the device.
This will happen as the program is loaded, before your VB validating code even gets a chance to run.
Click to expand...
Click to collapse
Ironically, the reason i'm developing this code is because i had 2 users try and run the program on a rom that didn't have .net 3.5 and it thusly crashed.
So i guess i wasting my time?
It is looking that way.
Incidentally, to find out which version(s) of .NET CF are on your device, just run cgacutil.exe in the \Windows subdirectory of your device.
It pops up a message box with the version(s) installed, as per attached image.

Categories

Resources