Using windows objects?
Using windows objects?
The new com stuff looks great but, it can be used to acces the windows objects(shell,browser,etc..) easily?, without an example it's a bit difficult to figure out how it works in PB.
- Psychophanta
- Always Here

- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
- Psychophanta
- Always Here

- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
You can see PB C.O.M. (ActiveX) code at:
http://robsite.de/php/pureboard/viewtop ... hlight=com
and if you don't understand german, then can use this to translate:
http://translation.paralink.com/urlmode.asp
I requested for André Beer to collect OOP small examples made with this PB 3.80 release, for his work; PB code-archive (www.purearea.net), and he is waiting for new C.O.M. (ActiveX) and DX OOP stuff here in this forum and in the german one to include it in the PureBasic code-archive.
Thanx !)
http://robsite.de/php/pureboard/viewtop ... hlight=com
and if you don't understand german, then can use this to translate:
http://translation.paralink.com/urlmode.asp
I requested for André Beer to collect OOP small examples made with this PB 3.80 release, for his work; PB code-archive (www.purearea.net), and he is waiting for new C.O.M. (ActiveX) and DX OOP stuff here in this forum and in the german one to include it in the PureBasic code-archive.
Thanx !)
Thanks, that gave me the clue. here's a simple example of the taskbar object based on a code by Danilo i think. it removes the window caption from the taskbar.
now it's much easier. this increases the scope of PB. we still have to work at the CLSID and IID, maybe it could be included in some resident?
Code: Select all
CoInitialize_(0)
hwnd=OpenWindow(0,10,10,500,500,#PB_Window_SystemMenu,"Hello World")
if CoCreateInstance_(?CLSID_TaskbarList,0,1,?IID_ITaskbarList,@pobj.ITaskbarList)=0
pobj\HrInit()
pobj\DeleteTab(hwnd)
Repeat
Until WaitWindowEvent()=#PB_EventCloseWindow
pobj\Release()
endif
end
DataSection
CLSID_TaskbarList:
Data.l $56FDF344
Data.w $FD6D,$11D0
Data.b $95,$8A,$00,$60,$97,$C9,$A0,$90
IID_ITaskbarList:
Data.l $56fdf342
Data.w $FD6D,$11D0
Data.b $95,$8A,$00,$60,$97,$C9,$A0,$90
EndDataSectionIt's been over six months (and one hd crash) so I need to check this out later but I have old code that returns ID's given the name of the object, ie, to help emulate statements in other languages like "an_object = CreateObject("Excel")". Maybe the same could/should now be built-in to PB to complement the new COM features ala "id = GetCLSID("obj_name")"? I think this actually is what my code did.
Hopefully I have misread the post but wouldn't it be an awful waste if CLSID's, which are already stored in the registry, are reproduced again in a res file?
Another question, my memory fails me, but if you are creating a brand new COM object how do you go about getting an ID for it? My understanding is that they are unique to the class across machines or am I wrong?
I'm deeply in 3D at the mo but already envisaging a COM interface to my engine.
Edit: Yo! Here yer go!...
Hopefully I have misread the post but wouldn't it be an awful waste if CLSID's, which are already stored in the registry, are reproduced again in a res file?
Another question, my memory fails me, but if you are creating a brand new COM object how do you go about getting an ID for it? My understanding is that they are unique to the class across machines or am I wrong?
I'm deeply in 3D at the mo but already envisaging a COM interface to my engine.
Edit: Yo! Here yer go!...
Code: Select all
Structure CLSIDa
Data1.l;
Data2.w;
Data3.w;
Data4.b[8];
EndStructure
Structure CLSIDb
d.b[36]
EndStructure
clsExcelApp.CLSIDa
;clsExcelApp.CLSIDb
ProgID.s = "Excel.Application"
IDBufferLen.w = 2*Len(ProgID)+2
IDBuffer = AllocateMemory(9, IDBufferLen)
;int MultiByteToWideChar(
; UINT CodePage, // code page
; DWORD dwFlags, // character-type options
; LPCSTR lpMultiByteStr, // address of string to map
; int cchMultiByte, // number of characters in string
; LPWSTR lpWideCharStr, // address of wide-character buffer
; int cchWideChar // size of buffer
; );
IDLen.w = MultiByteToWideChar_(#CP_ACP, 0, ProgID, -1, IDBuffer, IDBufferLen)
If IDLen=0
Debug "MultiByteToWideChar Failed"
End
EndIf
;HRESULT CLSIDFromProgID( LPCOLESTR lpszProgID, //Pointer to the ProgID
; LPCLSID pclsid //Pointer to the CLSID
;);
;result.l = CLSIDFromProgID_(IDBuffer, @pclsExcelApp.l);
result.l = CLSIDFromProgID_(IDBuffer, @clsExcelApp);
Select result
Case #S_OK
Debug "The CLSID was retrieved successfully."
;WINOLEAPI StringFromCLSID( REFCLSID rclsid, ; //CLSID To be converted
; LPOLESTR * ppsz ; //Indirect pointer to the resulting string on Return
;);
result = StringFromCLSID_( clsExcelApp, @pCS.l)
If result = #S_OK
cs.s = Space(32*2-1)
;int WideCharToMultiByte(
; UINT CodePage, // code page
; DWORD dwFlags, // performance and mapping flags
; LPCWSTR lpWideCharStr, // address of wide-character string
; int cchWideChar, // number of characters in string
; LPSTR lpMultiByteStr, // address of buffer for new string
; int cchMultiByte, // size of buffer
; LPCSTR lpDefaultChar, // address of default for unmappable characters
; LPBOOL lpUsedDefaultChar // address of flag set when default char. used
; );
CSLen.w = WideCharToMultiByte_(#CP_ACP, 0, pCS, -1, @cs, Len(cs), 0, 0)
If CSLen
Debug "%"+cs+"%"
SetClipboardText(cs)
Else
Debug "WideCharToMultiByte Failed!"
EndIf
EndIf
Case #CO_E_CLASSSTRING
Debug "The registered CLSID For the ProgID is invalid."
Case #REGDB_E_WRITEREGDB
Debug "An error occurred writing the CLSID to the registry"
EndSelect
By reading you posts, I come up with this: we could store the CSLID and such complex variables in a string and then have a function to get a pointer to this. The big advantage is it can be put in the resident easily.
Code: Select all
#IID_DirectDraw7 = "$10,$11,$0110,$FF10,$FF10"
And then:
Address = GetCLSID(#IID_DirectDraw7)
OK, maybe I am missing the plot so here's another example...
Code: Select all
Structure CLSIDa
Data1.l;
Data2.w;
Data3.w;
Data4.b[8];
EndStructure
Structure CLSIDb
d.b[36]
EndStructure
clsid.CLSIDa
;clsid.CLSIDb
;ProgID.s = "Excel.Application"
ProgID.s = "DIRECT.DirectX8.0"
IDBufferLen.w = 2*Len(ProgID)+2
IDBuffer = AllocateMemory(9, IDBufferLen)
IDLen.w = MultiByteToWideChar_(#CP_ACP, 0, ProgID, -1, IDBuffer, IDBufferLen)
If IDLen=0
Debug "MultiByteToWideChar Failed"
End
EndIf
result.l = CLSIDFromProgID_(IDBuffer, @clsid);
Select result
Case #S_OK
Debug "The CLSID was retrieved successfully."
result = StringFromCLSID_( clsid, @pCS.l)
If result = #S_OK
cs.s = Space(32*2-1)
CSLen.w = WideCharToMultiByte_(#CP_ACP, 0, pCS, -1, @cs, Len(cs), 0, 0)
If CSLen
Debug "%"+cs+"%"
SetClipboardText(cs)
Else
Debug "WideCharToMultiByte Failed!"
EndIf
EndIf
Case #CO_E_CLASSSTRING
Debug "The registered CLSID For the ProgID is invalid."
Case #REGDB_E_WRITEREGDB
Debug "An error occurred writing the CLSID to the registry"
EndSelect
The suggestion to get a CreateObject() with PureBasic looks nice to me, since I don't understand all the other stuff very well. The Interface options isn't very clear. The advanced example DirectX7.pb doesn't use the Interface option at all!!
I'm not that familiar with CLSID and programming COM, I like to keep it (Pure)Basic, like using ActiveXObject (with Javascript). I turned to PureBasic to get compiled applications. I have some ActiveX dll's that I could use with Javascript, but how do I use them with PureBasic?
The code provided by dmoc works fine with me, but what do I do with that CLSID? May be that's a curse, but I can't help it. Who can give me a clue how to use my ActiveX dll's ?
I'm not that familiar with CLSID and programming COM, I like to keep it (Pure)Basic, like using ActiveXObject (with Javascript). I turned to PureBasic to get compiled applications. I have some ActiveX dll's that I could use with Javascript, but how do I use them with PureBasic?
The code provided by dmoc works fine with me, but what do I do with that CLSID? May be that's a curse, but I can't help it. Who can give me a clue how to use my ActiveX dll's ?
That is not right! But you cannot see the Interface-Declaration in this example because it is implemented in PureBasic (Resident File InterfaceDX.res in folder ...\PureBasic\Residents\).aXend wrote:The advanced example DirectX7.pb doesn't use the Interface option at all!!
In the code of the DirectX 7.pb you find:
Code: Select all
...
If CallFunction(0,"DirectDrawCreateEx",0,@DirectDraw.IDirectDraw7,?IID_IDirectDraw7,0) <> #DD_OK
...
If DirectDraw\CreateSurface(SurfaceDescriptor, @PrimarySurface.IDirectDrawSurface7, 0) <> #DD_OK
...cu, helpy
See: can someone shed some light on interfacedx.res ?aXend wrote:How can I look into this resident file?
cu, helpy


