Announcement

Collapse
No announcement yet.

Has anyone translated LMDFS

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Has anyone translated LMDFS

    Has anyone translated the LMDFS Header file?

    or have a sample of using NetDfsGetInfo API call they would not mind sharing?

    Thanks in Advance

  • #2
    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.

    You can find those files here:

    http://www.jose.it-berater.org/smffo...hp?board=344.0

    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

    Comment


    • #3
      Thank you and Jose' as well
      :worship:

      Comment


      • #4
        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

        Comment


        • #5
          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)
          You are doing it too hard. Just use:

          Code:
              Folderpath = UCODE$("\\DFSServer\DFSROOT\DIR1")
              Result = NetDFSGetInfo(STRPTR(FolderPath), %NULL, %NULL, 3, DFSData)
          Forum: http://www.jose.it-berater.org/smfforum/index.php

          Comment


          • #6
            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.

            MCM
            Michael Mattias
            Tal Systems Inc. (retired)
            Racine WI USA
            [email protected]
            http://www.talsystems.com

            Comment


            • #7
              Thanks again Jose' and Michael for your insight

              Jose' I went with your way much cleaner than the way I was doing it

              Comment

              Working...
              X