You are not logged in. You can browse in the PowerBASIC Community, but you must click Login (top right) before you can post. If this is your first visit, check out the FAQ or Sign Up.
José Roca has translated that header and a lot of others in to powerbasic inlcude files. His translations are based on the C headers. He has done a great job of it. I just checked and he does have the LMDFS header converted and ready to use.
Note: You must register and sign in before you will be able to download the files. But his site is loaded with good advice and information, so it is well worth it.
Hope that helps,
"I haven't lost my mind... its backed up on tape... I think??" :D
Here is the somewhat working test code. Only nagging question is why it fails with invalid paramter unless in the MultibytetoWideChar you include either
ACODE$(StrToUnicode(FolderPath))
or "\\DFSSERVER\DFSROOT\DIR" States, looking for a pointer if I do not include acode$ I get 1722 error invalid parameter.
Test code for NetDFSGetInfo:
Code:
'Includes Contributed by: Jose Roca
#INCLUDE "WIN32API.inc" '<-- JRoca includes
#INCLUDE "LM.inc" '<-- NetAPIBufferFree declare
#INCLUDE "LMDFS.inc" '<-- NetDFS include
'From Powerbasic Forum (www.powerbasic.com)
'Contributed by George Bleck 12/1/2001
FUNCTION UnicodePtrtoStr(BYVAL dwdConvert AS DWORD) AS STRING
LOCAL lngLength AS LONG
LOCAL strBuffer AS STRING
lngLength = lstrlenw(BYVAL dwdConvert)
strBuffer = SPACE$(lngLength)
widechartomultibyte 0, %NULL, BYVAL dwdConvert, lngLength, BYVAL STRPTR(strBuffer), _
LEN(strBuffer), BYVAL %NULL, BYVAL %NULL
FUNCTION = strBuffer
END FUNCTION
'From Powerbasic Forum (www.powerbasic.com)
'Contributed by George Bleck 12/1/2001
FUNCTION StrToUnicode(BYVAL sConvert AS STRING) AS STRING
LOCAL lngLength AS LONG
LOCAL strBuffer AS STRING
lngLength = LEN(sConvert)
strBuffer = SPACE$(lngLength * 2)
MultiByteToWideChar 0, %NULL, BYVAL STRPTR(sConvert), lngLength, BYVAL STRPTR(strbuffer), LEN(strBuffer)
FUNCTION = strBuffer + CHR$(0,0)
END FUNCTION
FUNCTION PBMAIN () AS LONG
LOCAL DFSData AS DFS_INFO_3 PTR
LOCAL Result AS DWORD
LOCAL FolderPath AS STRING, wstrEntryPath AS ASCIIZ * (2 * %MAX_PATH)
LOCAL dwdResult AS DWORD
Folderpath = "\\DFSServer\DFSROOT\DIR1" '<-- This must point to valid DFS server will not use drive letter mapping
multibytetowidechar %CP_ACP, 0, ACODE$(StrToUnicode(FolderPath)), -1 , BYVAL VARPTR(wstrEntryPath), %MAX_PATH
dwdResult = VARPTR(wstrEntryPath)
Result = NetDFSGetInfo(dwdResult, %NULL, %NULL, 3, DFSData)
IF result = 0 THEN
MSGBOX "\\" & UnicodePtrtoStr(@[email protected]) & _
"\" & UnicodePtrtoStr(@[email protected])
NetAPiBufferfree(DFSData)
ELSE
MSGBOX "Failure Reason: " & STR$(Result)
END IF
END FUNCTION
Last edited by Ronald Robinson; 15 Jun 2009, 03:37 PM.
Reason: Added comment to a section
Only nagging question is why it fails .... if I do not include acode$ I get 1722 error invalid parameter
If you reference a PB "ASCIIZ" datatype (wStrEntryPath), it is assumed to terminate on the first $NUL. If your actual string is unicode, that means it will probably terminate on the second byte. Then when you convert that, you don't convert the whole string
You might have better luc with those unicode paths using something like
Code:
%UNICODE_BUFFER_SIZE = %MAX_PATH * 2 + 2
LOCAL wStrEntryPath AS STRING* %UNCODE_BUFFER_SIZE
Except that won't work either come to think of of because PB treats simple assignment to fixed string data type as though it were "LSET USING $SPC" , which is not what you want.... (why the compiler does that is a mystery to me. if I wanted LSET using $SPC, I'd LSET USING $SPC, ok? Please don't 'help' me like this!)
What you want is "TYPE SET wStrEntryPath = UCODE$(ansi_string) USING $NUL"
The compiler really could use a "WSTRINGZ * size" data type so we would not have to screw around dealing with the Unicode nulls ourselves.
We process personal data about users of our site, through the use of cookies and other technologies, to deliver our services, and to analyze site activity. For additional details, refer to our Privacy Policy.
By clicking "I AGREE" below, you agree to our Privacy Policy and our personal data processing and cookie practices as described therein. You also acknowledge that this forum may be hosted outside your country and you consent to the collection, storage, and processing of your data in the country where this forum is hosted.
Comment