Blog Home  Home Feed your aggregator (RSS 2.0)  
Peter Nowaks Mobile Blog - PInvoke
Windows Phone in the cloud
 
 Friday, July 10, 2009

As I’ve been talking in the past already, it is sometimes valuable, to create applications for the .NET CF, which are running unter the .NET Framework as well.

This can cause some issues on the .NET Framework, as you don’t have direct access to Environment variables and all enumerations from Environment.SpecialFolder when you probably need them.

But you can achieve access to this information through reflection.

For environment variables this is easy:

public static string ReadEnvironmentVariable(string variableName)
{
        return (string)typeof(Environment).InvokeMember("GetEnvironmentVariable", BindingFlags.Default | BindingFlags.InvokeMethod, null, "", new object[] { variableName });
}

 

The same applies to the SpecialFolder-Enumeration:

public static string ReadSpecialFolder(string variableName)
{
        return Environment.GetFolderPath((Environment.SpecialFolder)Enum.Parse(typeof(Environment.SpecialFolder), variableName, true));
}

 

Accessing both types of information is also easy. Please be aware of to do this only on the desktop system, via requesting the platform underneath:

if (Environment.OSVersion.Platform == PlatformID.Win32NT)
{
    string tempPath = ReadEnvironmentVariable("TEMP"));
    string localApplicationDataFolder = ReadSpecialFolder("LocalApplicationData");

}

Friday, July 10, 2009 8:14:42 AM (W. Europe Standard Time, UTC+01:00)  #    Comments [0]   .NET Compact Framework | P/Invoke  |  Trackback
 Thursday, July 24, 2008

Als günstige Alternative zur Positionsbestimmung lässt sich anstatt GPS die Position auch mittels Triangulation der Mobilfunkmasten bestimmen. Hierfür benötigt man u.a. die CellID - also die eindeutige Kennung des Mubilfunkmastes.

Dale Lane zeigt in seinem Blog, wie sich man diese Information programmatisch aus seiner verwalteten Anwendung via P/Invoke abfragen kann. Hierzu verwendet er als Schnittstelle den Radio Interface Layer (RIL). Offiziell wird die RIL jedoch nicht von Windows Mobile unterstützt, weswegen man mit der API vorsichtig umgehen sollte.

 

- English Version -

 

As a cheap alternative for retrieving your position, you can use instead of GPS a triangulation of your cell towers. Therefore you need the CellID - a unique identifier of the cell tower.

Dale Lane shows in his blog, how to request this info programatically from your managed application via P/Invoke. Therefore he uses the interface to the Radio Interface Layer (RIL). Officially RIL isn't supported by Windows Mobile, so you should be very carefull working with this API.

Thursday, July 24, 2008 4:46:08 PM (W. Europe Standard Time, UTC+01:00)  #    Comments [1]   .NET Compact Framework | P/Invoke | Windows Mobile  |  Trackback
 Tuesday, July 03, 2007

Sind Sie schon mal in die missliche Lage gekommen, daß Ihnen eine Schriftart unter Windows Mobile und somit auch in Ihrer Anwendung fehlt?

Mit ein wenig P/Invoke lässt sich dies schnell beheben:

[DllImport("coredll.dll", SetLastError = true)]
public static extern int AddFontResource(string lpName);

Rufen Sie in Ihrer Anwendung nur noch die Methode AddFontResource(@"\pfad\" + fontdateiname); auf, und schon können Sie die Schriftart in ihrer Anwendung verwenden.

Quelle: http://fabdecret.blogspot.com/2007/07/install-unicode-fonts.html

Tuesday, July 03, 2007 2:09:11 PM (W. Europe Standard Time, UTC+01:00)  #    Comments [2]   .NET Compact Framework | P/Invoke | Windows Mobile  |  Trackback
Copyright © 2010 Peter Nowak. All rights reserved.
DasBlog 'Portal' theme by Johnny Hughes.