views:

1504

answers:

2

Its basically the same as in windows, but when your trying to set file associations to a program that lives inside a folder that has spaces in it you need to get the "short" name of that folder. In regular windows i use this:

[System.Runtime.InteropServices.DllImport("Kernel32.dll")] private static extern uint GetShortPathName(string lpszLongPath, [Out] StringBuilder lpszShortPath, uint cchBuffer);

So my question becomes, does anyone know of a built in function i can use to replace the above function, or know of a exacly what this function does so i could recreate it in C#.

A: 

Who said you need the short path to set the file association in regular Windows? I just tried it myself real quick, and had no problems adding the keys to the registry with spaces. I then double checked the registry and sure enough, there are spaces there. The file type I associated with the program launches just fine, and the program lives in a directory with multiple spaces all over the place.

BFree
My question may not be clear enough, but the question is how to do this correctly on Windows mobile. I was using the example from regular windows in a attempt to make it more clear what i was looking for. ( And i have tested setting file associations to path with a space in WM and it failed for me).
EKS
I'll admit, I didn't try it on Windows Mobile (I'll try it tonight) but I did try it on Windows itself and had no issues. As for the answer to your question, I did some googling and there doesn't seem to be much. It shouldn't be THAT hard to write a function that would parse it and do it for you.
BFree
I did try this on my windows mobile 5 emulator, and found that you cannot set file associations to folders with spaces in them. I suspect i could be able to emulate the windows function. But that could create bugs that would be hard to track down
EKS
There's a guy here by the name of "ctacke" that's a guru in .NET CF (he's one of the guys on the OpenNetCF team: http://www.opennetcf.com/) I'm sure if there is a way to do it naively, he'll know how to do it and he'll answer your question sooner or later :)
BFree
A: 

Windows CE, which is the base of WinMo, doesn't use 8.3 file naming for anything, so I'm certain that you don't need to use them for defining file associations.

ctacke
I went out and retested this, and you are entirely correct. Thank you for you time
EKS