AVIRA AntiVirus barks only with Debugger enabledMarco2007 wrote:I bought the license for two years.
COMate - control COM objects via automation - OBSOLETE!
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

srod,
Very Nice, its already helpful in a project i'm working on. Thank you very much.
Tried it out on some vbs i had laying around, doesn't work in this type of vbs code tho:
and the flash demo doesn't work here on Vista Ultimate
Very Nice, its already helpful in a project i'm working on. Thank you very much.
Tried it out on some vbs i had laying around, doesn't work in this type of vbs code tho:
Code: Select all
strComputer = "."
Set objWMIService = GetObject( _
"winmgmts:\\" & strComputer & "\root\cimv2")
Set IPConfigSet = objWMIService.ExecQuery _
("Select IPAddress from Win32_NetworkAdapterConfiguration ")
For Each IPConfig in IPConfigSet
If Not IsNull(IPConfig.IPAddress) Then
For i=LBound(IPConfig.IPAddress) _
To UBound(IPConfig.IPAddress)
WScript.Echo IPConfig.IPAddress(i)
Next
End If
Next
> and the flash demo doesn't work here on Vista Ultimate
copy the flash to c: or change the path in the example. a absolute path is
required!
Works fine on Vista Ultimate 64
copy the flash to c: or change the path in the example. a absolute path is
required!
Works fine on Vista Ultimate 64
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Yes the flash demo requires an absolute url.
As for the VB code, you'd have to be more specific. I haven't added a FOREACH / NEXT macro and so you'll need to use the COMate_EnumObject() objects to enumerate the collection etc. Let me try and translate your code and see what happens?
I am just working on the ocx controls right now which is just about finished.
**EDIT : SFSxOI, your VB code is running fine here -at least up to a point. However, it uses SafeArrays and so I need to rummage around a bit before it will run!
As for the VB code, you'd have to be more specific. I haven't added a FOREACH / NEXT macro and so you'll need to use the COMate_EnumObject() objects to enumerate the collection etc. Let me try and translate your code and see what happens?
I am just working on the ocx controls right now which is just about finished.
**EDIT : SFSxOI, your VB code is running fine here -at least up to a point. However, it uses SafeArrays and so I need to rummage around a bit before it will run!
I may look like a mule, but I'm not a complete ass.
Can you provide an example on how you called that VBS script? Did you (or have you?) found a way to call PB functions from VBS?SFSxOI wrote:srod,
Very Nice, its already helpful in a project i'm working on. Thank you very much.
Tried it out on some vbs i had laying around, doesn't work in this type of vbs code tho:
and the flash demo doesn't work here on Vista UltimateCode: Select all
strComputer = "." Set objWMIService = GetObject( _ "winmgmts:\" & strComputer & "\root\cimv2") Set IPConfigSet = objWMIService.ExecQuery _ ("Select IPAddress from Win32_NetworkAdapterConfiguration ") For Each IPConfig in IPConfigSet If Not IsNull(IPConfig.IPAddress) Then For i=LBound(IPConfig.IPAddress) _ To UBound(IPConfig.IPAddress) WScript.Echo IPConfig.IPAddress(i) Next End If Next
@SFXxOI : I can get the following to work okay :
and so your VB code should not be a problem.
However, I was getting to the SafeArray part of the code you posted when I realised that I was getting just null returns from the enumeration. Now I think this is because of my computer setup rather than a problem with COMate. Can you give me a little more background as to what your script does and does my computer, for example, need to be part of a network or some such in order for your VB code to produce results? It is difficult to finish translating your VBS snippet without knowing what I should be expecting?
Code: Select all
XIncludeFile "COMate.pbi"
Define.COMateObject objWMIService, processorObject
collection.COMateEnumObject
strComputer.s = "."
objWMIService = COMate_GetObject("winmgmts:\\" + strComputer + "\root\cimv2", "")
If objWMIService
collection = objWMIService\CreateEnumeration("ExecQuery('Select * from Win32_Processor')")
If collection
processorObject = collection\GetNextObject()
While processorObject
Debug processorObject\GetStringProperty("currentClockSpeed")
processorObject\Release()
processorObject = collection\GetNextObject()
Wend
EndIf
EndIf
However, I was getting to the SafeArray part of the code you posted when I realised that I was getting just null returns from the enumeration. Now I think this is because of my computer setup rather than a problem with COMate. Can you give me a little more background as to what your script does and does my computer, for example, need to be part of a network or some such in order for your VB code to produce results? It is difficult to finish translating your VBS snippet without knowing what I should be expecting?
I may look like a mule, but I'm not a complete ass.
> I can get the following to work okay
There comes only one speed on my dual core? Is this okay?
There comes only one speed on my dual core? Is this okay?
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.

SFSxOI : can you run the following to see what kind of variants are being returned? I need to know the value being debugged?
Code: Select all
XIncludeFile "COMate.pbi"
Define.COMateObject objWMIService, IPConfig
IPConfigSet.COMateEnumObject
*var.VARIANT
strComputer.s = "."
objWMIService = COMate_GetObject("winmgmts:\\" + strComputer + "\root\cimv2", "")
If objWMIService
IPConfigSet = objWMIService\CreateEnumeration("ExecQuery('Select IPAddress from Win32_NetworkAdapterConfiguration')")
If IPConfigSet
IPConfig = IPConfigSet\GetNextObject()
While IPConfig
If IPConfig
*var = IPConfig\GetVariantProperty("IPAddress")
Debug *var\vt
VariantClear_(*var)
IPConfig\Release()
EndIf
IPConfig = IPConfigSet\GetNextObject()
Wend
EndIf
EndIf I may look like a mule, but I'm not a complete ass.
@Kiffi, I have your VB ActiveX code running okay. I just need to make a change to COMate...
I am guessing, but I don't think even DispHelper would work with this code of yours?
**EDIT : Here's the COMate code :
As you can see I have added a 'BYREF' modifier for parameters. With VB com servers it is not enough to simply pass the address of a variable to a VB method expecting an address... you also have to specify that the parameter is a pointer in the underlying variant! I know for a fact that DispHelper doesn't do this!
You will have to wait until I upload an update to COMate in order to run this as I am still working on the OCX stuff (just converting examples now) and I wish to get to the bottom of SFSxOI's problem. Although I think that his problematic code is just one of using safearrays etc.
**EDIT : Here's the COMate code :
Code: Select all
XIncludeFile "COMate.pbi"
object.COMateObject
a.l = 20
object = COMate_CreateObject("ActiveXTest.clsActiveXTest")
If object = 0
COMate_RegisterActiveXServer("Projekt1.dll")
object = COMate_CreateObject("ActiveXTest.clsActiveXTest")
EndIf
If object
object = COMate_CreateObject("ActiveXTest.clsActiveXTest")
If object
object\Invoke("Test1(" + Str(@a) + " as long BYREF)")
object\Release()
EndIf
COMate_UnRegisterActiveXServer("Projekt1.dll", #False)
Debug "New value of a is " + Str(a)
EndIf
You will have to wait until I upload an update to COMate in order to run this as I am still working on the OCX stuff (just converting examples now) and I wish to get to the bottom of SFSxOI's problem. Although I think that his problematic code is just one of using safearrays etc.
Last edited by srod on Thu Sep 04, 2008 2:07 am, edited 1 time in total.
I may look like a mule, but I'm not a complete ass.
This is what your above returns:srod wrote:SFSxOI : can you run the following to see what kind of variants are being returned? I need to know the value being debugged?
Code: Select all
XIncludeFile "COMate.pbi" Define.COMateObject objWMIService, IPConfig IPConfigSet.COMateEnumObject *var.VARIANT strComputer.s = "." objWMIService = COMate_GetObject("winmgmts:\" + strComputer + "\root\cimv2", "") If objWMIService IPConfigSet = objWMIService\CreateEnumeration("ExecQuery('Select IPAddress from Win32_NetworkAdapterConfiguration')") If IPConfigSet IPConfig = IPConfigSet\GetNextObject() While IPConfig If IPConfig *var = IPConfig\GetVariantProperty("IPAddress") Debug *var\vt VariantClear_(*var) IPConfig\Release() EndIf IPConfig = IPConfigSet\GetNextObject() Wend EndIf EndIf
Code: Select all
1
1
1
1
8204
1
1
1
1
1
1
Code: Select all
Define.COMateObject objWMIService, IPConfig
Define.s strComputer = "."
objWMIService = COMate_GetObject("winmgmts:\" + strComputer + "\root\cimv2", "")
If objWMIService
IPConfig = objWMIService\ExecQuery("Select IPAddress from Win32_NetworkAdapterConfiguration")
If IPConfig
While IPConfig
Debug IPConfig\IPAddress
EndIf
Wend
EndIf
EndIf
The code you just posted... well, I'm sorry, but it's nowhere near a valid translation to Purebasic with COMate!
You're attempting to execute COM methods on internal COMate objects! You have also not created an enumeration of IPAddress objects etc. Someone hasn't read the COMate manual!
You need to look at the code of mine which you ran as a test, that is how we must proceed. What your test has confirmed is that we simply need to complete the code.
The 8204 was what I was after!
The 1's represent null returns, presumably from adapters with no ip address. You should modify the query to filter these values out. Should be easy enough.
The 8204 tells us that one adaptor does indeed have an ip address and the enumeration has returned a safearray of variants! All we need to do is figure out how to get our hands on the array and then the variants within the array!
Difficult for me because I can't run the code in order to make tests as I proceed etc; I have no network adapters yielding any results and I do not have enough experience with SafeArrays to figure out the code whilst running blind!
Still, I'll certainly have a look tomorrow.
The 8204 was what I was after!
The 8204 tells us that one adaptor does indeed have an ip address and the enumeration has returned a safearray of variants! All we need to do is figure out how to get our hands on the array and then the variants within the array!
Still, I'll certainly have a look tomorrow.
I may look like a mule, but I'm not a complete ass.
- Michael Vogel
- Addict

- Posts: 2824
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact:
Just loaded the examples but have a small problem with Demo_Agent.pb:
when the user closes the agent 'manually' (right click and "hide"), the program still continues with its steps. How can I recognize that the agent has been closed? All invokes lines still return '0' and GetProperties returns the same pointer.
Any
when the user closes the agent 'manually' (right click and "hide"), the program still continues with its steps. How can I recognize that the agent has been closed? All invokes lines still return '0' and GetProperties returns the same pointer.
Any


