Just a quick Net function query this time (he says...) 
Author Message
 Just a quick Net function query this time (he says...)

Can someone help me sort out why the following code doesn't work? I think it
should because I am using StrPtr in the same way with other API-related
functions in my code. I can also get the function to work by using the
horrible spaghetti-code method of using a null-terminated array of Bytes,
but I'd rather it worked with the much more legible StrPtr. :)

The error it raises is Nerr_DCNotFound.

Private Declare NetApiBufferFree lib etc etc
Private Declare Function NetGetDCName Lib "netapi32.dll" (ByVal p_ServerName
As Long, ByVal p_DomainName As Long, ByVal p_Buffer As Long) As Long

Public Function GetPDCName(Optional server As String, Optional domain As
String) As String
    Dim result As Long
    Dim pdcName As String   'temp string used because I don't feel it is
safe to use strPtr() on the function!

    result = NetGetDCName(StrPtr(server), StrPtr(domain), StrPtr(pdcName))

    If result = NERR_SUCCESS Then
        GetPDCName = pdcName
    End If

    NetApiBufferFree StrPtr(pdcName) ' Free the buffer

    If result <> 0 Then
        Err.Raise result, App.Title & ".network.GetPDCName::NetGetDCName",
getErrString(result)
    End If
End Function

--
Cheers,

Sam



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 1 post ] 

 Relevant Pages 

1. ACC2K: Function in query expression called multiple times

2. help: text justed in reports access

3. How to query the Version No. of say MS/IE.

4. scriptcontrol error messages don't say what function they are in

5. MS Agent saying time and date

6. Crystal says Date-Time is a String

7. DVD drive says "Incorrect Function:...

8. function used in query repeats for each query value

9. Query takes 0 seconds in Query Analyzer, times out in VB

10. Quick Question about writing long queries

11. web service and updating web reference with vb.net design time vs run time

12. ADO.Net to fetch ActiveDirectory this function bugs in Asp.net but works in Vb.n

 

 
Powered by phpBB® Forum Software