COMate - control COM objects via automation - OBSOLETE!

Developed or developing a new product in PureBasic? Tell the world about it.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

We're talking about the PB code not the VB code.
I may look like a mule, but I'm not a complete ass.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Post by Kwai chang caine »

In PB he said "Variable no found"
ImageThe happiness is a road...
Not a destination
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Blooming heck Kwai!!!

My advice - take what you've learned about COMate and start translating the code from the beginning. First make sure that the VB code runs okay and then translate the code one line at a time. Test at every stage using the COMate_GetLastErrorDescription() function.

COMate has been so well used now that I don't think that any of the remaining bugs (if any? :wink: ) will prevent the successful conversion of what looks to be some quite simple code here.

If this doesn't work then read the COMate manual more carefully.
I may look like a mule, but I'm not a complete ass.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Post by Kwai chang caine »

Ok Ok, i go to search alone :cry:
If i really don't find, i will be back (Like TERMINATOR :lol:)

The VB code works very fine, i'm sure

I wish you a very good day and thanks again for your great works.

For christmas i have a big present for you.
I try to forgot you :lol:
*
*
*
*
*
*

*
*
*
*
*

*
*
*






But it's impossible :lol:
ImageThe happiness is a road...
Not a destination
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Post by Kwai chang caine »

You are right, i have found the problem.
I believe it's a bad declaration of variable :oops:

I have another simple question.
In french the quote character is severaly used.
But when i use it in the line

Code: Select all

SujetMail = "Envoi d'un mail" <---- A quote is present in this line
MailNote\SetProperty("Subject = '" + SujetMail + "'")
The subject don't appears :shock:
I have try with chr(39) but it's the same problem
Is it normal ??
I mean is because you use the quote for replace the double quote :roll:
Can i circle this problem ???

Thanks for your answer
ImageThe happiness is a road...
Not a destination
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Read the bloody manual you idiot!

:twisted:

In a command string, single quotes are used to signify a string parameter (which COMate needs to identify up front). I used a single quote instead of double quotes to make it easier to use PB's string functions etc.

Now this of course means that we cannot enter any single quotes within our command strings - at least not directly. Because of this COMate allows you to use 'escape codes' of the form $xxxx where xxxx denotes a hexadecimal unicode character code. For single quotes use $0027 (asc code 39).

So your latest code should read :

Code: Select all

SujetMail = "Envoi d$0027un mail" <---- A quote is present in this line 
MailNote\SetProperty("Subject = '" + SujetMail + "'")
Now, any more problems and you know what to read first before hitting the post button! :wink:
I may look like a mule, but I'm not a complete ass.
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Post by Kwai chang caine »

Idiot :shock:
I have the same name in french, it's strange no :D

Excuse me, master SROD
I'm a bad PADAWAN :oops:

My problem, it's not that i don't want read your doc.
I know that a doc is very hard to create.
And the IDIOT like me, don't take the time to read it :evil:

But i have just do 2 years of english, there are 30 years ago.
It's very very very hard for me to understand the english when it talk of the sun and the rain.
But when it talk of technical language, in a line i don't understand. :?

Excuse me again for disturb you, but you are my hero, with the other CAID member of this forum.
And if a day you can speak with your hero .....the real batman, or GOD, or Daredevil, spiderman, .........

What is your choice ????
Talk with your dream for example SPIDERMAN or read "STRANGE" the book who he is painted :lol:

All the hero have his "ball and chain".
You have found your first :D

Don't missing, i respect you and the forum member very much 8)
I have just a little head, without brain
My mother have no cliked the option when she create me.
I do without, it's difficult, but i fight this all the day.

Again thanks, for your kind answer, and your patience 8)
If you travel in france, I give you a meal
It's the minimal that i can do for you :wink:

The IDIOTMAN (Cool name :roll:)
Now, thanks SROD, me too i have a super hero name :D
ImageThe happiness is a road...
Not a destination
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

hehe, you are one funny guy Kwai - even if I don't understand half of what you say!!! :wink:

I take your point though about trying to read a technical guide in English - aye that's fair enough! :) I have the same problem when I look at my car repair guide - even though it's written in English it may as well be in Swahili!!!! I mean, what the hell is an engine dipstick? I though a dipstick was that guy who lives in Australia and goes by the name of Fangbeast!!! :twisted:

Kwai, I think we should start a separate thread titled "Kwai chang caine's coding questions!" where you can post away! Better still, perhaps one of the mods will open up a new forum section just for you?

hehe. Only kidding.
I may look like a mule, but I'm not a complete ass.
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4789
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Post by Fangbeast »

Kwai, don't bother asking that short assed, runty, bow legged, cave dwelling, g-string sniffing, car crashing, dog reaming hamster botherer srod anything else because I have to kill him again. Third time this month damn it!!

Come to think of it, his festering, steaming, decayed carcass smells like fertiliser already because of what he keeps doing to his own dipstick. You know, that 3 inch one on his finger!!!


MWUAHAHAHAHAHAHA!
User avatar
Kwai chang caine
Always Here
Always Here
Posts: 5494
Joined: Sun Nov 05, 2006 11:42 pm
Location: Lyon - France

Post by Kwai chang caine »

even if I don't understand half of what you say!!!
Oooohh like me :D
Finally like me and GOOGLE TRANSLATE :lol:

It's the proof that we can smile without understand :lol:
Kwai, I think we should start a separate thread titled "Kwai chang caine's coding questions!" where you can post away! Better still, perhaps one of the mods will open up a new forum section just for you?
Yeeeees !! the only THREAD with one thousand question and no answer :D
FRED even abandoned to answer to me.
I'm sure he believe i'm crazy :oops:
Or perhaps, he said to him : "If i answer only one time at one of this thousand question, i'm dead :twisted:
In fact KCC is like the SCOTCH, or the CHEWING-GUM under the shoes.
impossible to separate it :lol:
It's the reason why, even he is french, i have never speak to GOD.

Well, i love you all.......
When I grow up I want to be SROD, FLYPE, GNOZAL, TSSOFT, KIFFI, SPARKIE, NETMAESTRO ...... :roll:
Your code is like the music for my eyes 8)
Each time, i click run in my IDE, i'm like a kid the day of christmas :D
For you all, it's programming, for me it's each time a miracle :shock:

And your kindness is equal at your knowledge

In fact, you and me it's the DREAM TEAM.......
I have all the question, and you have all the answer :lol:

I said that often, but my dream is the same that your nightmare.........,
..............BE YOUR FRIEND............. :D

But i'm proud.
I was already the jester of FLYPE :D
Now i'm the IDIOT of SROD 8)
I moove i moove in the programing, I have two promoted :D
ImageThe happiness is a road...
Not a destination
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

I may look like a mule, but I'm not a complete ass.
nicolaus
Enthusiast
Enthusiast
Posts: 456
Joined: Tue Aug 05, 2003 11:30 pm
Contact:

Post by nicolaus »

First i must say that this lib is very nice!!!

Now i have one question.
I play with WMI and it works very well but i have a problem if i want receive informations about the CPU.
I use "Win32_Processor" and my problem is now that it works fine if the CPU is a single core CPU but if you have a 2 Core or more CPU i receive every time only the datas from CPU0 (DeviceID).

How can i receive also the next Devices with COMate?

Thanks,
Nico
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Can you post your code?

Here's some that I've just run. With a core 2 processor it only lists cpu0. Should it list two?

Code: Select all

IncludePath "..\..\"
XIncludeFile "COMate.pbi"

Procedure Get_Processors() 
   Protected objWMIService.COMateObject, processor.COMateObject 
   Protected colProcessor.COMateEnumObject 

   strComputer.s = "." 
   objWMIService = COMate_GetObject("winmgmts:\\" + strComputer + "\root\cimv2", "") 
   If objWMIService 
      colProcessor = objWMIService\CreateEnumeration("ExecQuery('Select * FROM Win32_Processor')") 
      If colProcessor 
         processor = colProcessor\GetNextObject() 
         While processor
            Debug processor\GetStringProperty("DeviceID")
            processor\Release() 
            processor = colProcessor\GetNextObject() 
         Wend 
         colProcessor\Release() 
      EndIf 
      objWMIService\Release()  
   EndIf 
EndProcedure 

Get_Processors()
I may look like a mule, but I'm not a complete ass.
nicolaus
Enthusiast
Enthusiast
Posts: 456
Joined: Tue Aug 05, 2003 11:30 pm
Contact:

Post by nicolaus »

srod wrote:Can you post your code?

Code: Select all

XIncludeFile "COMate.pbi"

Procedure.s WMI_CPU_Info() 
  Define.COMateObject objWMIService, CPU 
  cenuCPU.COMateEnumObject 
  strComputer.s = "." 
  Net_I_Index$ = Str(Interface_Index) 
  objWMIService = COMate_GetObject("winmgmts:\" + strComputer + "\root\cimv2", "") 
  If objWMIService  
    cenuCPU = objWMIService\CreateEnumeration("ExecQuery('Select * from Win32_Processor')")
    If cenuCPU 
      CPU= cenuCPU\GetNextObject() 
      While CPU
        Debug "Caption                      =   " + CPU\GetStringProperty("Caption")
        Debug "Name                           = " + CPU\GetStringProperty("Name") 
        Debug "DeviceID                       = " + CPU\GetStringProperty("DeviceID") 
        Debug "MaxClockSpeed                 =   " + Str(CPU\GetIntegerProperty("MaxClockSpeed")) 
        CPU\Release() 
        CPU = cenuCPU\GetNextObject() 
      Wend 
      cenuCPU\Release() 
    EndIf
    
    objWMIService\Release()  
  EndIf 
EndProcedure 

WMI_CPU_Info()
And i have one more question, can you show an example how i can also write with WMI? the examples in the lib do only read via WMI but it is very nice if we can see how we can write via COMate and WMI.

Thanks,
Nico
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post by srod »

Sorry I don't use wmi very much.
I may look like a mule, but I'm not a complete ass.
Post Reply