WMI with harbour / HMG / Extended Version

Discuss anything else that does not suite other forums.

Moderator: Rathinagiri

Post Reply
User avatar
AUGE_OHR
Posts: 182
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany
Has thanked: 17 times
Been thanked: 21 times

WMI with harbour / HMG / Extended Version

Post by AUGE_OHR » Sun Nov 10, 2019 11:58 pm

hi,

i want to run a WMI Script. i found c:\MiniGUI\SAMPLES\Advanced\WMI_Service\ and Demo work :D
so i take FUNCTION WMIService() ... but it make Problem :(

i does run with Debugger but crash without it :o
i have modify Code this Way

Code: Select all

STATIC FUNCTION WMIService()
*-----------------------------
Static oWMI
Local oLocator

   if oWMI == NIL
      oLocator := CreateObject( "wbemScripting.SwbemLocator" )
ALTD()
      IF EMPTY(oLocator)
         msginfo("can not create wbemScripting.SwbemLocator")
      ELSE
         hb_idleSleep(1)
         // this line crash without Debugger  
         oWMI:= oLocator:ConnectServer()
      ENDIF
   endif

Return oWMI
Error WINOLE/1007 Ein ausgehender Aufruf kann nicht ausgeführt werden, da die Anwendung einen eingabe-synchronisierten Aufruf weiterleitet. (0x8001010D): SWbemLocator (DOS Error -2147352567)
Called from TOLEAUTO:CONNECTSERVER(0)
Called from WMISERVICE(146)
Called from WMI_INFO(117)
Called from USB_DETECT(72)
Called from EVENTPROCESS(161)
Called from DOMESSAGELOOP(0)
Called from _ACTIVATEWINDOW(5737)
Called from MAIN(35)
i also include a hb_idleSleep(1) but it does not help.

why does it run with Debugger but not without :?:

User avatar
AUGE_OHR
Posts: 182
Joined: Sun Aug 25, 2019 3:12 pm
DBs Used: DBF, PostgreSQL, MySQL, SQLite
Location: Hamburg, Germany
Has thanked: 17 times
Been thanked: 21 times

Post by AUGE_OHR » Mon Nov 11, 2019 3:06 am

hi,

Code: Select all

CREATE EVENT PROCNAME USB_Detect() HWND Form_1.HANDLE STOREINDEX nIndex
it work THX :D
but how go on :?:

when i got DBT_DEVICEARRIVAL i want to do "more" but IMHO it is not a good place in this loop.
i think that's why my WMI Call fail without Debugger.

as it is a function i can give RETURN a value but than :idea:

---

under Xbase++ i "send" a Usedef Event to Main-loop an there i can react on it.

from Thread

Code: Select all

   CASE nWParam == DBT_DEVICEARRIVAL
      // more API
      PostAppEvent(xbeSD_Arrive,nDrive,,oMain)
in Main

Code: Select all

   DO WHILE .NOT. lExit = .T.
      nEvent := APPEVENT( @mp1, @mp2, @oXbp, 100 )
      DO CASE
         CASE nEvent = xbeSD_Arrive
            IF EMPTY(mp1)
               cDrive := ""
            ELSE
               cDrive := CHR( 65 + mp1 )   // A-Z :( 
            ENDIF
            TestDrive( cDrive, oDlg )
so how do it with harbour / HMG :?:

Post Reply