Page 2 of 39

Posted: Wed Sep 03, 2008 9:25 pm
by ts-soft
Marco2007 wrote:I bought the license for two years.
AVIRA AntiVirus barks only with Debugger enabled
:wink:

Posted: Wed Sep 03, 2008 9:28 pm
by Marco2007
@TS-Soft: Thanx for the info! You`re right!

@Berikco: Image Image Image

Posted: Wed Sep 03, 2008 10:59 pm
by SFSxOI
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:

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

Posted: Wed Sep 03, 2008 11:05 pm
by ts-soft
> 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 :wink:

Posted: Wed Sep 03, 2008 11:12 pm
by srod
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! :)

Posted: Thu Sep 04, 2008 12:00 am
by X
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:

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
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?

Posted: Thu Sep 04, 2008 12:01 am
by srod
@SFXxOI : I can get the following to work okay :

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 
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? :)

Posted: Thu Sep 04, 2008 12:14 am
by ts-soft
> I can get the following to work okay
There comes only one speed on my dual core? Is this okay?

Posted: Thu Sep 04, 2008 12:20 am
by srod
I guess so! :) I only get one result as well.

Posted: Thu Sep 04, 2008 12:30 am
by srod
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 

Posted: Thu Sep 04, 2008 1:03 am
by srod
@Kiffi, I have your VB ActiveX code running okay. I just need to make a change to COMate... :wink: I am guessing, but I don't think even DispHelper would work with this code of yours?

**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
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. :)

Posted: Thu Sep 04, 2008 1:38 am
by SFSxOI
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 
This is what your above returns:

Code: Select all

1
1
1
1
8204
1
1
1
1
1
1
and this is the code I was using after converting the vbs and using your include:

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

Posted: Thu Sep 04, 2008 1:53 am
by srod
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! :wink: 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! :wink: 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! :wink: 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. :)

Posted: Thu Sep 04, 2008 3:58 am
by byo
srod, it's ingenious. Thank you.

Posted: Thu Sep 04, 2008 9:36 am
by Michael Vogel
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 :idea: