benötige die CLSID von einen Remote Server da das Objekt nicht Local installiert ist.
Um die Registry von eine Remote Server auszulesen muss wohl erst über den Service Control Manager eine Bindung hergestellt werden.
FF

Code: Alles auswählen
Enumeration
#Window_0
#Frame3D_0
#Text_comp
#String_comp
#Text_User
#String_User
#String_pwd
#button_connect
#Text_pwd
#Text_dom
#Combo_0
#Button_exit
#status
EndEnumeration
Global C.s
Declare.s RegEnumKey(hKey.l, sKey.s, pc.s)
;SCM
#SERVICE_WIN32_OWN_PROCESS = $10
#SERVICE_WIN32_SHARE_PROCESS = $20
#SERVICE_WIN32 = #SERVICE_WIN32_OWN_PROCESS + #SERVICE_WIN32_SHARE_PROCESS
#SERVICE_ACCEPT_STOP = $1
#SERVICE_ACCEPT_PAUSE_CONTINUE = $2
#SERVICE_ACCEPT_SHUTDOWN = $4
#SC_MANAGER_CONNECT = $1
#SC_MANAGER_CREATE_SERVICE = $2
#SC_MANAGER_ENUMERATE_SERVICE = $4
#SC_MANAGER_LOCK = $8
#SC_MANAGER_QUERY_LOCK_STATUS = $10
#SC_MANAGER_MODIFY_BOOT_CONFIG = $20
#SERVICES_ACTIVE_DATABASE = "ServicesActive"
;SRV Info
Structure SERVER_INFO_101
dwPlatformId.l
lpszServerName.l
dwVersionMajor.l
dwVersionMinor.l
dwType.l
lpszComment.l
EndStructure
#MAX_PREFERRED_LENGTH = -1
#SV_TYPE_ALL =$FFFFFFFF
#NERR_SUCCESS = 0
#ERROR_MORE_DATA = 234
#SV_TYPE_DOMAIN_ENUM = $80000000
Procedure GetServerList()
StatusBarText(#Status, 0, "check network...")
se101.SERVER_INFO_101
nStructSize = SizeOf(SERVER_INFO_101)
RetCode = NetServerEnum_(0, 101, @bufptr, #MAX_PREFERRED_LENGTH, @dwEntriesread, @dwTotalentries, #SV_TYPE_DOMAIN_ENUM, 0, @dwResumehandle)
If RetCode = #NERR_SUCCESS And RetCode <> #ERROR_MORE_DATA ;Loop through And the Data in the memory
For i = 0 To dwEntriesread - 1
CopyMemory( bufptr + (nStructSize * i),@se101, nStructSize)
Buffer.s=Space(512)
Result=WideCharToMultiByte_(#CP_ACP ,0,se101\lpszServerName,255,@Buffer.s,512,0,0)
Debug result
;ProcedureReturn Buffer
;Debug @se101
AddGadgetItem(#Combo_0,-1,Buffer)
StatusBarText(#Status, 0, Buffer )
; Debug buffer ;AddGadgetItem(#Gadget_TV, -1, Buffer,UseImage(0))
Next
EndIf
NetApiBufferFree_(bufptr)
;ProcedureReturn buffer
EndProcedure
Procedure PrintStuff(interval)
Repeat
Print(".")
Delay(interval)
ForEver
EndProcedure
Procedure ConnectDrive(Resource.s,UserName.s,Password.s)
Debug "username: " + UserName
Debug "password: " +Password
Debug "sharename: "+ Resource
NetR.NETRESOURCE
ErrInfo.l
MyPass.s
MyUser.s
NetR\dwScope = #RESOURCE_GLOBALNET
NetR\dwType = #RESOURCETYPE_DISK
NetR\dwtype=#RESOURCETYPE_ANY
NetR\dwDisplayType = #RESOURCEDISPLAYTYPE_SHARE
NetR\dwUsage = #RESOURCEUSAGE_CONNECTABLE
;NetR\lpLocalName =@Drive.s; If undefined, Connect with no device
NetR\lpRemoteName =@Resource.s; Your valid share
;NetR.lpComment = "Optional Comment"
;NetR.lpProvider = ; Leave this undefined
; If the UserName and Password arguments are NULL, the user context
; for the process provides the default user name.
ErrInfo = WNetAddConnection2_(NetR, Password, UserName, #CONNECT_UPDATE_PROFILE)
If ErrInfo = #NO_ERROR
Debug Resource +" Connected Successful!"
StatusBarText(#Status, 0, Resource +" Connected Successful!")
StatusBarText(#Status,0,RegEnumkey(#HKEY_CLASSES_ROOT,"CLSID\{00000100-0000-0010-8000-00AA006D2EA4}",GetGadgetText(#String_Comp)))
Else
Debug Resource +" ERROR: " +Str( ErrInfo )
StatusBarText(#Status, 0, Resource +" ERROR: " +Str( ErrInfo ) )
EndIf
EndProcedure
Procedure Open_SCM(Computer.s)
thread = CreateThread(@PrintStuff(), 500)
lhSCManager.l
lhService.l
lResult.l
lhSCManager = OpenSCManager_(Computer, #SERVICES_ACTIVE_DATABASE, #SC_MANAGER_ALL_ACCESS)
If lhSCManager <> 0
Debug "SCM OK"
KillThread(thread)
ProcedureReturn 1
CloseServiceHandle_(lhSCManager)
Else
Debug "SCM no access ..."
KillThread(thread)
ProcedureReturn 0
EndIf
EndProcedure
Procedure Open_logonremote(Computer.s)
;EnableWindow_(WindowID(#Window), #False)
If OpenWindow(#Window_0, 501, 27, 238, 211, "Connect to remote computer", #PB_Window_SystemMenu | #PB_Window_TitleBar | #PB_Window_BorderLess )
If CreateGadgetList(WindowID(#Window_0))
Frame3DGadget(#Frame3D_0, 10, 10, 220, 140, "Admin credential for the remote computer")
CreateStatusBar(#status, WindowID(#Window_0))
TextGadget(#Text_comp, 20, 40, 80, 20, "Computername:")
TextGadget(#Text_User, 20, 65,80, 20, "Username:")
TextGadget(#Text_pwd, 20, 90, 90, 20, "Password:")
StringGadget(#String_comp, 110, 40, 110, 20, Computer)
StringGadget(#String_User, 110, 65, 110, 20, "administrator")
StringGadget(#String_pwd, 110, 90, 110, 20, "", #PB_String_Password)
ButtonGadget(#Button_connect,10, 155, 100, 30, "Connect")
TextGadget(#Text_dom, 20, 120, 60, 20, "Domain:")
ComboBoxGadget(#Combo_0, 110, 120, 110, 80)
ButtonGadget(#Button_exit, 130, 155, 100, 30, "Cancel")
EndIf
EndIf
AddGadgetItem(#Combo_0,-1,Computer)
;AddGadgetItem(#Combo_0,-1,GetServerList())
SetGadgetState(#Combo_0,0)
EndProcedure
Procedure.s RegEnumKey(hKey.l, sKey.s, pc.s)
ret.l
hnd.l
vKey.s
vSize.l
vLWT.FILETIME
remhnd.l
Index.l
;pc=UNC(pc)
ret=RegConnectRegistry_(pc, hKey, @remhnd)
If ret=#ERROR_SUCCESS
ret=RegOpenKeyEx_(remhnd, sKey, 0, #KEY_ALL_ACCESS, @hnd)
If ret=#ERROR_SUCCESS
Index=0
ret$=""
While ret=#ERROR_SUCCESS
vSize=255 : vKey=Space(255)
ret=RegEnumKeyEx_(hnd, Index, @vKey, @vSize, 0, 0, 0, @vLWT)
If ret=#ERROR_SUCCESS
ret$=ret$+vKey+"; "
ElseIf Index=0
ret$="*error: cannot enumerate keys*"
Else
ret$=Left(ret$,Len(ret$)-2)
EndIf
Index+1
Wend
Else
ret$="*error: cannot access key*"
EndIf
Else
ret$="*error: cannot access remote registry*"
EndIf
RegCloseKey_(remhnd)
ProcedureReturn ret$
EndProcedure
;-start
C.s=LCase(ProgramParameter())
OpenConsole()
PrintN("connect to SCM on: " +C)
resu=Open_SCM(C)
If resu=1
PrintN("SCM connect successfully!")
PrintN("connect to remote reg..")
PrintN(RegEnumkey(#HKEY_CLASSES_ROOT,"CLSID\{00000100-0000-0010-8000-00AA006D2EA4}",C))
thread = CreateThread(@PrintStuff(), 500)
Delay(5000)
KillThread(thread)
End
Debug "connect"
Else
PrintN("")
PrintN("No Access Right!")
Delay(1000)
CloseConsole()
Open_logonremote(C)
thrid=CreateThread(@GetServerList(),0)
EndIf
;Debug ProgramParameter()
; Until Quit
Repeat
event=WaitWindowEvent()
If event=#PB_Event_Gadget
Select EventGadget()
Case #button_connect ;ButtonGadget
Debug GetGadgetText(#String_Comp)
;Die Freigabe IPC$ wird bei temporären Verbindungen zwischen Clients und Servern über Named Pipes
;für die Kommunikation zwischen Netzwerkprogrammen verwendet. Sie wird in erster Linie für die Remoteverwaltung
;von Netzwerkservern genutzt.
ConnectDrive("\\"+GetGadgetText(#String_Comp)+"\ipc$",GetGadgetText(#Combo_0)+"\"+GetGadgetText(#String_User),GetGadgetText(#String_pwd))
Case #button_exit
End
EndSelect;And EventGadget()=1
EndIf
Until event=#PB_Event_CloseWindow
Code: Alles auswählen
Procedure.s ReadRegKey(hKey.l,sKey.s,ValueName.s, pc.s)
keyvalue.s=Space(255)
datasize.l=255
If RegConnectRegistry_(pc, hKey, @remhnd) = #ERROR_SUCCESS
If RegOpenKeyEx_(remhnd, sKey, 0, #KEY_ALL_ACCESS, @hnd) <> #ERROR_SUCCESS
keyvalue="Error Opening Key"
Else
If RegQueryValueEx_(hnd,ValueName,0,0,@keyvalue,@datasize) <> #ERROR_SUCCESS
keyvalue="Error Reading key"
Else
keyvalue=Left(keyvalue,datasize-1)
EndIf
RegCloseKey_(hKey)
EndIf
RegCloseKey_(remhnd)
Else
keyvalue="Error Connect to " + pc
EndIf
ProcedureReturn keyvalue
EndProcedure
c.s = "" ; PC-Name
temp.s = ReadRegkey(#HKEY_CLASSES_ROOT,"ADODB.Connection\CurVer","", C)
Debug temp
temp.s = ReadRegkey(#HKEY_CLASSES_ROOT, temp + "\CLSID" ,"" , C)
Debug temp
Code: Alles auswählen
RegGetValue("HKEY_LOCAL_MACHINE\SOFTWARE\BIN","Test2",".")