Public Function GetDesktopName() As String
Dim hDesktop As Long
Dim lR As Long
Dim lSize As Long
Dim sBuff As String
Dim iPos As Long
hDesktop = OpenInputDesktop(0, False, DESKTOP_READOBJECTS)
If Not (hDesktop = 0) Then
lSize = (Len(m_sDesktop) + 1) * 2
ReDim bBuff(0 To lSize - 1) As Byte
lR = GetUserObjectInformation(hDesktop, UOI_NAME, bBuff(0), lSize, lSize)
sBuff = bBuff
iPos = InStr(sBuff, vbNullChar)
If (iPos > 1) Then
sBuff = Left(sBuff, iPos - 1)
End If
GetDesktopName = sBuff
CloseHandle hDesktop
End If
End Function
I think the following is essentially what you need. It won't run 'as is' because of the missing variable 'm_sDesktop' and you'll have to double check the buffer size etc.
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.