Open text files - Windows Mobile Development and Hacking General

I am developing an app to open text files in windows mobile.
sample of the code I am using
fs = System.IO.File.OpenText(Fname)
While (Not fs.EndOfStream) And (Not StopRead)
System.Windows.Forms.Application.DoEvents()
fs.ReadLine()
RecordsInFile = RecordsInFile + 1
End While
fs.Close()
This code is used to count the records in the file.
I get error when trying to open files having non english ( for eg: ü) characters.
So I converted the file to UTF encoding.
The file opens properly.
But the non english characters are not dispalayed properly.
The problem is on windows mobile only.
But all these files open properly and characters displayed correctly on Windows desktop.
Is there any other method to open the files Properly?
Anyone help plz

Related

HOWTO: programmaticaly create a shortcut to a file/folder

hi,
I need to create a shortcut to a file or folder using eVC++ 4.0, anybody knows how to do this??
Thaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaanx alot
Mohammad
It's very easy:
Just create a file (with lnk extension)
and write to it:
10#"my_app.exe" -launch
this is what it means:
10 - length of the string after #. This value doesn't have to be accurate because it is usually ignored.
"my_app.exe" - path and name of the target of the shortcut.
-launch - command line parameters (if you have any)
You can also add: ?incon.exe,0 to take an icon from another exe / dll
Thaaaaaaaaaaaaaaank you very very much,
but I need a small thing, could you please provide me with a complex example so I can understand all features supported for shortcuts.
Thank you again,
Mohammad
Mo.
A number of us have posted about the structure of the .lnk file.
Search against my username for the word completeness.
V
now, I searched and got how the thing works, but I have a problem with coding this stuff:
When I attemp to write to shortcut file like this:
strData.Format(_T("%d#\"%s\""),strFilename.GetLength(), element.strPathname);
ShortcutFile.Write(strData,strData.GetLength()*2);
The file is not written correctly, what I get is the data I wrote in the file with a square charecter after each letter like this:
#□4□0□"□\□S□t□o□r□a□g□e□ □C□a□r□d□\□M□y□P□r□o□g□r□a□m□.□E□x□e□"□
so how can I solve this? and does it relate to unicode?
That's because you are trying to write it in UNICODE. This adds zero to every byte.
You must use fopen, fprintf, fclose functions or just create an array of char and use FileWrite to create an ASCII text file.
Thanks levenum,
but isn't windows ce file system unicode based? if so, how can I use ASCII format to write unicode filenames?
Thanks alot
Mohammad
#include <Oleauto.h>
......
char convertUshortToChar(unsigned short in)
{
char con='\0';
VarI1FromUI2(in,&con);
return con;
}
and add Oleaut32.lib to the list of object/library moduals in you project settings.
just call that for each unicode character that you want to be ascii and write the result to file.
Two things:
a) The file system may be UNICODE, but shortcuts are ASCII text. Also ASCII functions like fopen are supported.
b) There is a much easier way to convert UNICODE to ASCII:
mbstowcs(unicodeStrBuffer, asciiStrBuffer);
OK, I did it, but I think that there is a problem with Windows mobile, and it is a big problem.
Till now, I beleive that you cannot create a shortcut to a unicode-named file, I failed to do that, File explorer was not successful, Resco Explorer was not better.
Worse, they do not tell you that you cant create the shortcut, they create the shortcut for you and when you try to open it they conclude that the path was not found!!.
Very bad huh?
Mohammad
I thought that all file names are in unicode?? Use my shortcut creator in GSMbeam file open dialog to try and make a shortcut to a file named like you said. If that shortcut dose not work send me the file in question and I will try and see whats going on.
Ok, I downloaded your program and tried to create a shortcut for an arabic-named file, simply it did not work.
I know its not a bug in ur program, its a bug in Windows Mobile, it is mainly a bug in the design itself, how does Micro$oft design windows mobile to be unicode based while non-ascii characters are not supported in the shell links, its really a shame.
You can be sure that this will happen with asian characters along with Farsi, Hebrew, Arabic and all non-ascii characters.
Programmatically, what happens is as follows:
1. A program converts a filename from unicode to ASCII to save it in the .lnk file.
2. If the file name contains non-ASCII characters, those will be converted to NULL character.
3. When the shell tries to resolve the link target it does not recognise the filename because some characters are NULL.
Thats what I found out!!
Take this file name for example (Arabic): 2مرحبا.mp3
Try to solve the issue, and please inform us whatever happens with you..
Best Regards,
Mohammad
So the problem is how to get the shell to read unicode in lnk files. I re-wrote a lnk file in unicode to see if it would work but it would not. There are a lot of non english ppc users, surely this problem has come up before?
As an experiment I also made shortcut to a folder using utf-8, I think that contains arabic characters and also the ascii characters. After removing some garbage that my editor put at the front of the lnk file worked fine. Try making a shortcut in notepad and saving it as a utf-8 file then rename it on your device but make sure there is no extra characters.
أنا قادر على أكل الزجاج و هذا لا يؤلمني. -- I think those characters are arabic and they are copied of a utf-8 table site so if the shell can read a utf-8 lnk that contains english letters then maybe it can do the arabic too.
Actually, non English UNICODE characters are translated in to extended ASCII codes (128 - 255). When the system needs to translate these codes back to UNICODE it relies on code page definitions in the wince.nls file.
If your locale is properly set to Arabic and you have a valid nls installed (ether you have Arabic ROM or some sort of Arabic language support installed) you should be able to reference Arabic file names using ASCII links.
So, can I depend on string conversion functions we discussed before in this topic to convert characters according to my code page?
I have an arabic ROM installed on my Wizard, it is the i-mate rom on O2 device, so the arabizer doesnt work well, may be because the serial number of the O2 device.
Anyway, I should invistigate this issue on my friend's JamIn device, and we should come up with a workaround for this wiered problem.
Regards all,
Mohammad
OK,
I have tried creating a shortcut on my friend's arabic-enabled JamIn device, the shortcut refers to arabic-named file and it worked good.
levenum, you are right, it depends on the code page on each device, so your device will not be able to create a shortcut to an arabic named file.
Mohammad

Resizing fields in File Explorer

I have the following problem - for example when I open word mobile and it shows me the files i have in the default word directory, the first column (the file name) is so small that i cannot make out which file to open because it only shows the first 2 letters of the file name. When i open the same directory through File Explorer the file name is clearly visible. This is very irritating when working with a lot of files in any application (word, exel, notes, etc.). I am using a Gullum VII rom, and I can't remember whether or not I had this problem with the original wm5 rom. Is there any way of tinkering with registry values to solve this problem?

[solution] Unable to display attachment

I have had this problem, and gone mad for two days: poutlook suddenly couldn't anymore open the atachments, while i was able to save them and open. So it was not a corrupted database... Also searching on the board, i have found only a bunch of maydays, but no solutions.
Finally, i found the trick, so i share it if someone else will unfortunately have the same problem. Simply, was deleted the temporary folder where attachments are stored to be displayed.
Well, here is what to do if you'll have the problem.
1. Check HKLM\System\Inbox\Attachments
You''l have 5 subkeys:
AttDir = Inbox.mstxxxxxxxx.xxxxxxxx (same name of the folder where attachments are stored either in sd card or device)
BottomDir = Attachments (or whatever is in your language)
Middledir = Connections (or whatever is in your language)
Moving = DWORD 0
TopDir = Program Files (or whatever is in your language)
If you have not these entries, create them.
2. Open File Explorer or Resco or what you use
3.Make sure you have ON DEVICE the folders \Program Files\Connections\Mail Attachments\ (same names as above in the registry: of course they will change accordingly to your language)
4. If you haven't those folders, create them
5. Enjoy your working again attachments

[Updated] MPlayer for all device (latest svn)

Hi here is the latest MPLAYER for windows mobile it would run on almost all device
Instructions :
Install cab and click on mplayer icon. Use joystick for menu navigation
It support all codecs and you can customize it easily by editing
menu.conf for Menu Items
input.conf for key encodings
codecs.conf for codec related things
Limitation:
1. While playing it is not possible to hide mplayer window [SDL issue]
2. No UNICODE support. Support is not in cegcc so I am not able to do anything right now may be i will modify cegcc later.
In progrss:
1.real file support [90% done]
2.Directx support [50% done , if you want use directx edit config file and replace vo=sdl to vo=directx:noaccel and fs=1]
3.wma support [100% forgot to include in this release will add in next build]
[Note : all config files are in \My Documents\mplayer\ folder]
Log:
1. If you face any problem please send log.txt file from \Storage Card\ folder
Very Important:
1. Pls donate if you like my work
Click Here to donate
Download :
http://rapidshare.com/files/238300198/mplayer.cab.html
Placed everything in the right place and gave it a run. I have a Samsung Omnia with a WinMo 6.1 rom.
I noticed I doesn't seem to suport uniconde. The "Storage Card" drive is called "Cartão de Memória" in my localization and mplayer crashes everytime I tried to launch it... Really hope you fix this one. Also hope you add a simple GUI soon.
Also may I suggest that the file that need to be placed in the "My documents" folder be placed in the same folder as the mplayer.exe instead.
And please release the source.
doesent work for me, i tried to open AVI Files and MP3's too
this is the log file i have :
Code:
MPlayer SVN-r29318-4.1.0 (C) 2000-2009 MPlayer Team
135 audio & 296 video codecs
Playing \Storage.
File not found: '\Storage'
Failed to open \Storage.
Playing Card\Movies\Heroes_-_S01-_E05_-__Hiros_PocketPC.avi.
File not found: 'Card\Movies\Heroes_-_S01-_E05_-__Hiros_PocketPC.avi'
Failed to open Card\Movies\Heroes_-_S01-_E05_-__Hiros_PocketPC.avi.
Is there a GUI? Because I can't see anything when I launch it...
Click to expand...
Click to collapse
to run mplayer you need file explorer which support open with.
select media file and open with mplayer if you execute mplayer.exe directly nothing happen
Click to expand...
Click to collapse
There You have your answer
I noticed I missed that. I was already editing my post when you replied
Also just tried an FLV1 file from my device memory (from "Cartão de memória didn't work). At first the file wouldn't play but then I used WVGAFIX3 to change my device resolution from WQVGA to QVGA and it worked. Seems like it deslikes wide screens.
ather90 said:
doesent work for me, i tried to open AVI Files and MP3's too
this is the log file i have :
Code:
MPlayer SVN-r29318-4.1.0 (C) 2000-2009 MPlayer Team
135 audio & 296 video codecs
Playing \Storage.
File not found: '\Storage'
Failed to open \Storage.
Playing Card\Movies\Heroes_-_S01-_E05_-__Hiros_PocketPC.avi.
File not found: 'Card\Movies\Heroes_-_S01-_E05_-__Hiros_PocketPC.avi'
Failed to open Card\Movies\Heroes_-_S01-_E05_-__Hiros_PocketPC.avi.
Click to expand...
Click to collapse
use "enclose path in quotes" option if you are using resco explorer
frmariam said:
Placed everything in the right place and gave it a run. I have a Samsung Omnia with a WinMo 6.1 rom.
I noticed I doesn't seem to suport uniconde. The "Storage Card" drive is called "Cartão de Memória" in my localization and mplayer crashes everytime I tried to launch it... Really hope you fix this one. Also hope you add a simple GUI soon.
Also may I suggest that the file that need to be placed in the "My documents" folder be placed in the same folder as the mplayer.exe instead.
And please release the source.
Click to expand...
Click to collapse
attach log.txt , that will give better idea why exectution failed
For the directory name charater issue (Cartão de memória) it just crashes on launch. It was when I tried to launch mplayer directly (before I edited the post). I was however how I found the issue. If I try the "Open with" and the media file is in any dir which characters like those it just wont open...
Also strangelly enough the same video file is no longer crashing in WQVGA resolution?! Only GSFinder+ (my file manager) crashes. I did a reset since that so maybe it was a problem with my device and not mplayer. Still the character issue remains.
Here's the log.txt (media in "Cartão de memória") for when it failed and worked.log when it played (in a different path)
frmariam said:
For the directory name charater issue (Cartão de memória) it just crashes on launch. It was when I tried to launch mplayer directly (before I edited the post). I was however how I found the issue. If I try the "Open with" and the media file is in any dir which characters like those it just wont open...
Also strangelly enough the same video file is no longer crashing in WQVGA resolution?! Only GSFinder+ (my file manager) crashes. I did a reset since that so maybe it was a problem with my device and not mplayer. Still the character issue remains.
Click to expand...
Click to collapse
yes it is more likely because of no unicode support right now. I have idea how to support so that will be fixed in next build.
New mplayer download from first post and share your experiance
latest svn compile with menu and bgvideo support for audio files

Simple Text Editor - Notepad

Hi at all,
Often I need to use a simple text editor instead of a more complex (and heavy) programs (like word) just for create or edit simple text files, then I have written a very simple applicatation to view a text files (txt, log, bat, ...).
Notepad is a simple text editor with the possibility to open and save documents in differents text format. The notepad functionalities are intentionally left simple for not to be too heavy.
Funcionalities:
- Context menu' with Cut, Copy and Paste commands.
- Clipboard shared with other applications (is possibile to copy text from other application (like word) end paste in notepad, and viceversa)
- Insert today date (from edit menu' and from context menu')
- Delete current file from file system
- Open and save files in any folder browsing file system (instead of classic open file dialog)
Prerequisities :
- .NET Compact Framework 2.0 ( www.microsoft.com )
Installation.
Download zip file
unzip in any folder and copy CAB file on device.
Use fileExplorer to found a CAB file and run it.
It will be installed and will be created an icon in Program Files.
ScreenShot
http://free.hostingjava.it/-frusso/pda/frNotepad/notepadAnimationR.gif
Download
You can download it on my web page ( http://free.hostingjava.it/-frusso/pda/frNotepad ) or in attachment.
thank you for the notepad
Super software thx!

Categories

Resources