.Net question??

tsdt

Active Member
Licensed User
Hi all,

I know that this could not be the right place to ask this question, but, I was thinking maybe someone would know about this, as there are many experts in .net programming.

I am trying to look high and low on this issue. I know that we can use DeviceInfo to get the UUID, however, I was also trying to get the UUID using SystemParametersInfo.. I get 1439 Win39Error. I dont know what is wrong with it as the documentation in MSDN on this is only one line.

Can anyone point out what is wrong with this line? Thanks.

byte[] UUID = new byte[16];
const uint SPI_GETUUID = 263;

SystemParametersInfo(SPI_GETUUID, 0, ref UUID, 0);

:sign0013:
 

agraham

Expert
Licensed User
Longtime User
You haven't given the declaration you are using for SystemParametersInfo but I guess that the "ref UUID" parameter is incorrect. By using ref on an array variable you are passing a pointer to a reference value, hence a pointer to a pointer whereas SystemParametersInfo needs just a pointer. Try deleting "ref".
 

tsdt

Active Member
Licensed User

Thanks Agraham for your reply.

Yes, you are right about it. That will give me an exception telling me that this format is not supported. I have removed that and everything seems fine. However, SystemParametersInfo(...) is passing me back "Fail". When I check the Win32Error message, I got 1439, which means the parameter I sent in is incorrect. My suspects would be on the SystemParametersInfo second parameter and the fourth parameter. I dont know what they should be.

According to the msdn document, the second parameter should be set to zero if it does not specify anything. The fourth one, I also set it to zero as well. Dont know whether this is correct or not.

As for the declaration, I have called the dllImport.. Should not have any problem with that.

Any idea??

Thanks

:icon_clap:

Best regards
 

tsdt

Active Member
Licensed User
Post the declaration you are using and the code calling it. I can't suggest anything without seeing the code you are using.

Ok.. Thanks.

// DLL side:
========
private const uint SPI_GETUUID = 263;
private byte[] MSUUID;

public MSAPIWrapper(bool Device)
{
MSUUID = new byte[256];
}

public bool MS_GetUUID()
{
bool ret_value;
ret_value = SystemParametersInfoUUID(SPI_GETUUID, 256, MSUUID, 0);
return ret_value;
}

//Interface
public string sUUID
{
get
{
StringBuilder sb = new StringBuilder("");

sb.Append(String.Format("{0:X2}{1:X2}{2:X2}{3:X2}-{4:X2}{5:X2}-{6:X2}{7:X2}-{8:X2}{9:X2}-{10:X2}{11:X2}{12:X2}{13:X2}{14:X2}{15:X2}",
MSUUID[0],
MSUUID[1],
MSUUID[2],
MSUUID[3],
MSUUID[4],
MSUUID[5],
MSUUID[6],
MSUUID[7],
MSUUID[8],
MSUUID[9],
MSUUID[10],
MSUUID[11],
MSUUID[12],
MSUUID[13],
MSUUID[14],
MSUUID[15]));
return (sb.ToString());
}
}


[DllImport("coredll.dll", EntryPoint = "SystemParametersInfo", SetLastError=true)]
private static extern bool SystemParametersInfoUUID(uint uiAction,
UInt16 uiParam,
byte[] pvParam,
uint fWinIni);

Calling in Basic4ppc:
===============
WriteToTBInformation(CRLF & "*** MS UUID ***", False)
If (MSApiObj.MS_GetUUID = True) Then
WriteToTBInformation("MS UUID : " & MSApiObj.sUUID, False)
Else
WriteToTBInformation("MS UUID : Unknown " & MSApiObj.sWin32Error, False)
End If

Did I miss out anything?? :sign0089:
 

agraham

Expert
Licensed User
Longtime User
B4X:
[DllImport("coredll.dll", EntryPoint = "SystemParametersInfo", SetLastError=true)]
[COLOR="SeaGreen"][return: MarshalAs(UnmanagedType.Bool)][/COLOR]
private static extern bool SystemParametersInfoUUID(uint uiAction,
                                                            [COLOR="Red"]UInt16[/COLOR] uiParam,
                                                            byte[] pvParam,
                                                            uint fWinIni);
I think that uiParam should be a uint. Also my book on CF 2.0 implies that you might need the line in green to marshal the returned C++ 4 byte BOOL to a .Net Boolean, although I thought this would be automatic. If you have trouble you could also just declare the return as int or uint.
 

tsdt

Active Member
Licensed User

Thanks Agraham for your quick response.

I have tried your suggestion and unfortunately, the result kept on giving me 1439 as the error code.

By the way, Agraham, I have a few questions on .NET which I would like to ask you. I dont know whether this is the right place to put my .NET question or not. Hence, I was thinking if you have any other personal email which I can post my .NET questions?

Thanks.
 

agraham

Expert
Licensed User
Longtime User
From Googling the error 1439 is 'Invalid system wide SPI* parameter" meaning that SPI_GETUUID is not valid. Looking at the SDKs on my system it seems like it is only available on WM 6.0 or later like these other SPIs which were only added to winuser.h in the Windows Mobile 6.0 SDK.

#define SPI_GETPROJECTNAME 259
#define SPI_GETPLATFORMNAME 260
#define SPI_GETBOOTMENAME 261
#define SPI_GETPLATFORMMANUFACTURER 262
#define SPI_GETUUID 263
#define SPI_GETGUIDPATTERN 264
 

tsdt

Active Member
Licensed User

I am using Windows Mobile 6.5 Classic totest on this. Should be supported by right...
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…