.NET Framework - Problem with GetDeviceUniqueID on windows CE 5.0
Asked By Jay
17-May-07 03:14 PM

Hello all,
I am using
string AppString = "deviceappid";
byte[] AppData = new byte[AppString.Length];
for (int count = 0; count < AppString.Length; count++)
AppData[count] = (byte)AppString[count];
int appDataSize = AppData.Length;
byte[] DeviceOutput = new byte[20];
uint SizeOut = 20;
GetDeviceUniqueID(AppData, appDataSize, 1,
DeviceOutput, out SizeOut);
----------------------------------
[DllImport("coredll.dll")]
private extern static int GetDeviceUniqueID([In, Out] byte[]
appdata,
int
cbApplictionData,
int
dwDeviceIDVersion,
[In, Out] byte[]
deviceIDOuput,
out uint
pcbDeviceIDOutput);
----------------------------------
to retrieve the device id in our application.
retrieving the device id works fine on the windows mobile emulator and
our windows mobile 5 devices. When I try to run it on our Windows CE
5.0 platform I get the following error.
Can't find an Entry Point 'GetDeviceUniqueID' in a PInvoke DLL
'coredll.dll'
any help would be great..
thanks in advanced.
Jay
It's because that's a WM API. For generic CE you need to call
SystemParametersInfo with SPI_GETOEMINFO.
--
Chris Tacke, Embedded MVP
OpenNETCF Consulting
Managed Code in an Embedded World
www.OpenNETCF.com

function "?? _ _Elogger@@YAXXZ" (??_ _Elogger@@YAXXZ) dasdk.lib(DaSessionImp.obj) : error LNK2019: unresolved external symbol "_ _declspec(dllimport) public: long _ _thiscall uima::CAS::reset(void)" (_ _imp_?reset@CAS@uima@@QAEJXZ) referenced in function function _ _ehhandler$?initLogger@DaManagerImp@@AAEXXZ dasdk.lib(DaSessionImp.obj) : error LNK2019: unresolved external symbol "_ _declspec(dllimport) public: void _ _thiscall uima::SofaFS::setRemoteSofaURI(char const *)" (_ _imp_? setRemoteSofaURI@SofaFS@uima@@QAEXPBD@Z) referenced processURI@DaSessionImp@@EAEPAUFilteredDocument@@PBD@Z) dasdk.lib(DaSessionImp.obj) : error LNK2019: unresolved external symbol "_ _declspec(dllimport) public: _ _thiscall uima::SofaFS::SofaFS(void)" (_ _imp_??0SofaFS@uima@@QAE@XZ) referenced in function "private const *, . . .)" (?info@Category@log4cpp@@QAAXPBDZZ) dasdk.lib(DaSessionImp.obj) : error LNK2019: unresolved external symbol "_ _declspec(dllimport) public: virtual _ _thiscall icu_3_0::UnicodeString::~UnicodeString(void)" (_ _imp_?? 1UnicodeString@icu_3_0@@UAE@XZ) referenced in function createSourceSofa@DaSessionImp@@IAEXAAVSofaFS@uima@@@Z) dasdk.lib(DaManagerImp.obj) : error LNK2001: unresolved external symbol "_ _declspec(dllimport) public: virtual _ _thiscall icu_3_0::UnicodeString::~UnicodeString(void)" (_ _imp_?? 1UnicodeString@icu_3_0@@UAE@XZ) dasdk.lib(DaSessionImp.obj) : error LNK2019: unresolved external symbol "_ _declspec(dllimport) public: class uima::SofaFS _ _thiscall uima::CAS::createSofa(class uima::SofaID const &, char const *)" (_ _imp_ createSourceSofa@DaSessionImp@@IAEXAAVSofaFS@uima@@@Z) dasdk.lib(DaSessionImp.obj) : error LNK2019: unresolved external symbol "_ _declspec(dllimport) public: class uima::SofaID const & _ _thiscall uima::AnnotatorContext::mapToSofaID(class icu_3_0::UnicodeString const &)" (_ _imp_? mapToSofaID createSourceSofa@DaSessionImp@@IAEXAAVSofaFS@uima@@@Z) dasdk.lib(DaSessionImp.obj) : error LNK2019: unresolved external symbol "_ _declspec(dllimport) public: class uima::AnnotatorContext * _ _thiscall uima::AnnotatorContext::getDelegate(class icu_3_0::UnicodeString const &)const " (_ _imp_? getDelegate
dwSize; public IntPtr hrasconn; [MarshalAs(UnmanagedType.ByValTStr, SizeConst = (int) (RasFieldSizeConstants.RAS_MaxEntryName + 1))] public string szEntryName; } [DllImport("coredll.dll", CharSet = CharSet.Auto)] public extern static uint RasEnumEntries( string reserved, / / reserved, must be occurred uint dwExtendedError / / extended error information for some errors ); public partial class RASWrapper { protected RASWrapper() { } [DllImport("coredll.dll", CharSet = CharSet.Auto)] public extern static uint RasDial( [In]RASDIALEXTENSIONS lpRasDialExtensions, / / pointer to a handler for RasDial events ref IntPtr lphRasConn / / pointer to variable to receive / / connection handle ); [DllImport("coredll.dll", CharSet = CharSet.Auto)] public extern static uint RasHangUp( IntPtr hrasconn / / handle to the RAS connection to hang up ); [DllImport("coredll.dll", CharSet = CharSet.Auto)] public extern static uint RasGetErrorString( uint uErrorValue, / / error to get StringBuilder lpszErrorString, / / buffer to hold error string [In]int cBufSize / / size, in characters, of buffer ); [DllImport("coredll.dll", CharSet = CharSet.Auto)] public extern static uint RasEnumConnections( [In, Out]RASCONN[] lprasconn, / / buffer lpcb, / / size in bytes of buffer out int lpcConnections / / number of connections written to buffer ); [DllImport("coredll.dll", CharSet = CharSet.Auto)] public extern static uint RasEnumDevices( [In, Out]RASDEVINFO[] lpRasDevInfo, / / buffer of the buffer out int lpcDevices / / receives the number of / / entries written to the buffer ); [DllImport("coredll.dll", CharSet = CharSet.Auto)] public extern static uint RasGetConnectStatus( IntPtr hrasconn, / / handle to RAS connection of interest [In, Out]RASCONNSTATUS lprasconnstatus / / buffer to receive status data ); [DllImport("coredll.dll", CharSet = CharSet.Auto)] public extern static uint RasConnectionNotification( IntPtr hrasconn, / / handle to a
wawangvsrv1", 21, { fd.DownloadFile(". . / . . / public / hello.txt", @"c: \ temp \ hello.txt", false); } } } class FtpDownloader : IDisposable { [DllImport("WININET", EntryPoint = "InternetOpen", SetLastError = true, CharSet = CharSet.Auto)] static extern IntPtr InternetOpen( string lpszAgent, int dwAccessType, string lpszProxyName, string lpszProxyBypass, int dwFlags); [DllImport("WININET", EntryPoint = "InternetCloseHandle", SetLastError = true, CharSet = CharSet.Auto)] static extern bool InternetCloseHandle(IntPtr hInternet DllImport("WININET", EntryPoint = "InternetConnect", SetLastError = true, CharSet = CharSet.Auto)] static extern IntPtr InternetConnect( IntPtr hInternet, string lpszServerName, int nServerPort, string lpszUsername, string lpszPassword, int dwService, int dwFlags, int dwContext); [DllImport("WININET", EntryPoint = "FtpSetCurrentDirectory", SetLastError = true, CharSet = CharSet.Auto)] static extern bool FtpSetCurrentDirectory(IntPtr hConnect, string lpszDirectory); [DllImport("WININET", EntryPoint = "FtpGetFile", SetLastError = true, CharSet = CharSet.Auto)] static extern bool FtpGetFile( IntPtr hConnect, string either the InternetSetStatusCallback definition or the INTERNET_STATUS_CALLBACK delegate. Thanks again Matt public class MasterFtp : IDisposable { [DllImport("wininet.dll", SetLastError = true, CharSet = CharSet.Auto)] static extern IntPtr InternetOpen( string lpszAgent, int dwAccessType, string lpszProxyName, string lpszProxyBypass, int dwFlags); [DllImport("wininet.dll", SetLastError = true)] [return: MarshalAs(UnmanagedType.Bool)] static extern bool InternetCloseHandle(IntPtr hInternet DllImport("wininet.dll", SetLastError = true, CharSet = CharSet.Auto)] static extern IntPtr InternetConnect( IntPtr hInternet, string lpszServerName
_hFadeDesktop); User32.SwitchDesktop(_hFadeDesktop); MessageBox.Show("Test"); . . . . . . . . where the definition of create desktops look like: [DllImport("user32.dll")] public static extern IntPtr CreateDesktop(String lpszDesktop, IntPtr lpszDevice, IntPtr pDevmode, int dwFlags rights. Below is the corrected version of code snippet, which works well on my side: [DllImport("user32.dll")] private static extern IntPtr CreateDesktop(string lpszDesktop, IntPtr lpszDevice, IntPtr pDevmode, int dwFlags, int dwDesiredAccess, IntPtr lpsa); [DllImport("user32.dll")] public static extern bool SetThreadDesktop(IntPtr hDesktop); [DllImport("user32.dll")] public static extern IntPtr GetThreadDesktop(int dwThreadId DllImport("kernel32.dll")] public static extern int GetCurrentThreadId(); [DllImport("user32.dll")] public static extern bool SwitchDesktop(IntPtr hDesktop); / / desktop public const int DESKTOP_CREATEWINDOW = 0x0002 that it actually fails with error 170, which means "The requested resource is in use": [DllImport("user32.dll", SetLastError = true)] private static extern IntPtr CreateDesktop(string lpszDesktop, IntPtr lpszDevice, IntPtr pDevmode, int dwFlags, int dwDesiredAccess, IntPtr lpsa); [DllImport("user32.dll", SetLastError = true)] public static extern bool SetThreadDesktop(IntPtr hDesktop); [DllImport("user32.dll", SetLastError
public int dwSerialNumberSize; public int dwSerialNumberOffset; public int dwSubscriberNumberSize; public int dwSubscriberNumberOffset; } private class NativeTapi { [DllImport("coredll")] public static extern int lineClose(IntPtr hLine); [DllImport("cellcore")] public static extern int lineGetGeneralInfo(IntPtr hLine, byte[] bytes); [DllImport("coredll")] public static extern int lineGetAddressCaps(IntPtr hLineApp, int dwDeviceID, int dwAddressID, int dwAPIVersion, int dwExtVersion, byte[] lpAddressCaps); [DllImport("coredll")] public static extern int lineInitializeEx(out IntPtr lpm_hLineApp, IntPtr hInstance, IntPtr lpfnCallback, string lpszFriendlyAppName, out int lpdwNumDevs, ref int lpdwAPIVersion, ref LINEINITIALIZEEXPARAMS lpLineInitializeExParams); [DllImport("coredll")] public static extern int lineNegotiateAPIVersion(IntPtr m_hLineApp, int dwDeviceID, int dwAPILowVersion, int dwAPIHighVersion, out int lpdwAPIVersion, out LINEEXTENSIONID lpExtensionID); [DllImport("coredll")] public static extern int lineOpen(IntPtr m_hLineApp, int dwDeviceID, out IntPtr lphLine, int dwAPIVersion, int dwExtVersion, IntPtr dwCallbackInstance, int dwPrivileges, int dwMediaModes, IntPtr lpCallParams); [DllImport("coredll")] public static extern int lineShutdown(IntPtr m_hLineApp); } } Best luck Michal http: / / sakowicz.info On public int dwSerialNumberSize; public int dwSerialNumberOffset; public int dwSubscriberNumberSize; public int dwSubscriberNumberOffset; } private class NativeTapi { [DllImport("coredll")] public static extern int lineClose(IntPtr hLine); [DllImport("cellcore")] public static extern int lineGetGeneralInfo