P/invoke fejl. kan ikke finde coredll.dll
jeg har en klasse jeg har skrevet om til c# fra http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetcomp/html/netcfintrointerp.aspusing System;
using System.IO;
using System.Runtime.InteropServices;
namespace Wrapper.CeAPI
{
/// <summary>
/// Summary description for FileSystem.
/// </summary>
public class FileSystem
{
private FileSystem()
{
}
public enum ceFolders
{
PROGRAMS = 2, //Windows\Start Menu\Programs
PERSONAL = 5, //My Documents
STARTUP = 7, //Windows\StartUp
STARTMENU = 0x000b, //Windows\Start Menu
FONTS = 0x0014, //Windows\Fonts
FAVORITES = 0x0006 //Windows\Favorites
}
[DllImport("coredll.dll", SetLastError=true)]
private static extern bool SHGetSpecialFolderPath(
int hwndOwner,
string lpszPath,
ceFolders nFolders,
bool fCreate);
public static string GetSpecialFolderPath(ceFolders folder)
{
string sPath = new string(' ',260);
bool ret;
try
{
ret = SHGetSpecialFolderPath(0,sPath,folder,false);
}
catch(Exception ex)
{
HandleCeError(ex,"GetSpecialFolderPath");
return null;
}
if(!ret)
{
//API error retrieve the error number
int errorNum = Marshal.GetLastWin32Error();
HandleCeError(new WinCeException("SHGetSpecialFolderPath returned False, " +
"likely an invalid constant",errorNum),"GetSpecialFolderPath");
}
return sPath;
}
private static void HandleCeError(Exception ex, string method)
{
if(ex is NotSupportedException)
{
//Bad arguments og incorrectly declared
throw new WinCeException("Bad arguments or incorrect declaration in "+method,0,ex);
}
else if(ex is MissingMethodException)
{
//Entry point not found
throw new WinCeException("Entry point not found in "+method,0,ex);
}
else if(ex is WinCeException)
{
throw ex;
}
else
{
//All other exceptions
throw new WinCeException("Miscellaneous exception in "+method,0,ex);
}
}
}
public class WinCeException : ApplicationException
{
public int APIErrorNumber = 0;
public WinCeException()
{
}
public WinCeException(string message): base(message)
{
}
public WinCeException(string message, int apiError): base(message)
{
APIErrorNumber = apiError;
}
public WinCeException(string message,int apiError,Exception innerException): base(message,innerException)
{
APIErrorNumber = apiError;
}
}
}
jeg har derefter en form der kalder på følgende måde:
string docs="";
docs = Wrapper.CeAPI.FileSystem.GetSpecialFolderPath(Wrapper.CeAPI.FileSystem.ceFolders.PERSONAL);
Men jeg får fejlen at den ikke kan finde coredll.dll.
Jeg bruger en HP Jornada 760 (gammel sag)
Hvor skal jeg finde denne dll? eller hvad gøt jeg galt?
