|
-
Apr 26th, 2003, 07:11 AM
#1
Thread Starter
Fanatic Member
get and set Workgroup name [RESOLVED]
Does anybody know how to get and set the Workgroupname, using API or any other way? Please help.
Last edited by robbedaya; Sep 7th, 2003 at 03:43 AM.
- Use the thread tools to Mark your Thread as Resolved when your question is answered.
- Please Rate my answers if they where helpful.
-
Sep 7th, 2003, 03:40 AM
#2
Thread Starter
Fanatic Member
To Set the workgroup:
VB Code:
'in module'
Public Declare Function NetJoinDomain Lib "Netapi32" _
(ByVal lpServer As Long, _
ByVal lpDomain As Long, _
ByVal lpAccountOU As Long, _
ByVal lpAccount As Long, _
ByVal lpPassword As Long, _
ByVal fJoinOptions As Long) _
As Long
Public Function SetWorkgroup(WorkgroupName As String) As Long
Dim nRet As Long
Const strAccount As String = vbNullChar
Const strPassword As String = vbNullChar
WorkgroupName = WorkgroupName & vbNullChar
nRet = NetJoinDomain(ByVal 0&, StrPtr(WorkgroupName), ByVal 0&, StrPtr(strAccount), StrPtr(strPassword), NETSETUP_JOIN_UNSECURE)
SetWorkgroup = nRet
End Function
and just call it like this
VB Code:
'anywhere you want
SetWorkgroup Workgroupname
- Use the thread tools to Mark your Thread as Resolved when your question is answered.
- Please Rate my answers if they where helpful.
-
Sep 7th, 2003, 03:43 AM
#3
Thread Starter
Fanatic Member
to get the workgroup:
VB Code:
'In module
Type WKSTA_INFO_101
wki101_platform_id As Long
wki101_computername As Long
wki101_langroup As Long
wki101_ver_major As Long
wki101_ver_minor As Long
wki101_lanroot As Long
End Type
Declare Function NetWkstaGetInfo& Lib "Netapi32" _
(strServer As Any, ByVal lLevel&, pbBuffer As Any)
Declare Sub lstrcpyW Lib "kernel32" (dest As Any, ByVal src As Any)
Declare Sub RtlMoveMemory Lib "kernel32" _
(dest As Any, src As Any, ByVal size&)
Declare Function NetApiBufferFree& Lib "Netapi32" (ByVal buffer&)
Function GetWorkgroup() As String
Dim ret As Long, buffer(512) As Byte, i As Integer
Dim wk101 As WKSTA_INFO_101, pwk101 As Long
Dim langroup As String
ret = NetWkstaGetInfo(ByVal 0&, 101, pwk101)
RtlMoveMemory wk101, ByVal pwk101, Len(wk101)
lstrcpyW buffer(0), wk101.wki101_langroup
i = 0
Do While buffer(i) <> 0
langroup = langroup & Chr(buffer(i))
i = i + 2
Loop
ret = NetApiBufferFree(pwk101)
GetWorkgroup = langroup
End Function
Just call it like this:
[Highlight=VB]
'anywhere you want
- Use the thread tools to Mark your Thread as Resolved when your question is answered.
- Please Rate my answers if they where helpful.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|