![]() |
|
|||||||
| Discussion Discussion area for all things related to Jose's code. Posts and uploads are available to all forum members. |
![]() |
|
|
Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
A good use for this Forum - Discuss Metro/WinRT
Rather than make this forum a rehash of what is already on Jose's current forums, maybe it would be a good idea to start discussions on new topics where Jose would be a moderator and contributor.
IMO Jose may be one the best persons to lead a discussion about Metro and how to improve the PowerBasic compiler for building Metro applications. Also his knowledge would help all of us to start digging into the WinRT, which is not only used in Metro apps, but I have read that WinRT can also be accessed by desktop apps. So maybe add two new child forums to Joses Corner: Metro Discussions WinRT Discussions
__________________
Chris Boss Computer Workshop Developer of "EZGUI" http://cwsof.com http://twitter.com/EZGUIProGuy |
|
#2
|
|||
|
|||
|
Sorry to disappoint you, but besides not having Windows 8, I don't know more about Metro applications than you, and I don't have any expertise with the languages currently available to develop them.
Regarding WinRT, if Bob has already read the scarce preliminary documentation, he already knows what is needed to do. It is more a problem of PBers not being yet used to use low-level COM that anything else. I told Bob that having worked so hard to implement one of the best low-level COM support in any compiler, it is a crime that almost nobody is using it. So the purpose of this forum is to demonstrate that it is not so hard to use. Contrarily to Automation servers, most low-level COM servers don't come with type libraries. Why? Because these servers can not be used by Automation languages and have to be used with direct interface calls. Therefore, you can't simply take a browser to generate the interface definitions, but have to be translated from the ones in the C++ headers, just as we have to do with standard function declares. The PB includes don't provide any interface declarations; therefore, you can't use the low-level COM servers provided by Windows with them. Mine provide them, but there are differences in the translation of many of the declares that they have in common. Many that have tried them, have stopped at the first conflict, because having no good knowledge of the Windows API, don't know how to solve them, and others that only post in the PB Forums, prefer to use code that Semen or I wrote 8 or 10 years ago to no force the use of my includes. Anybody lurking this forum and seeing this kind of code still being used must thing that PB is an arcane compiler. So I have modified my headers to wrap the differences with #IF/ENDIFs. The only gotcha is that the PB includes and mine can't be mixed. Maybe one day we will got one version of the PB IDE with provision for more than one set of include files and a menu option to easily switch between them. My goal is that PBer's start to learn and use low-level COM. About 2/3 (a rough estimate) of the Windows 7 API are low-level COM servers and this proportion is only going to increase. If they don't, they won't be able to use any of the new technologies and WinRT will be the least of his problems.
__________________
Website: http://www.jose.it-berater.org/index.html SED Editor, TypeLib Browser. Forum: http://www.jose.it-berater.org/smfforum/index.php |
|
#3
|
|||
|
|||
|
Well then, why not use this new forum to help the rest of us get up to speed with Powerbasic COM and then let those of us who do have Windows 8 try to put it into practical use for accessing the WinRT.
Maybe a child form entitled: Prepare for WinRT by learning PB COM now
__________________
Chris Boss Computer Workshop Developer of "EZGUI" http://cwsof.com http://twitter.com/EZGUIProGuy |
|
#4
|
|||
|
|||
|
It's pretty hard to justify adding a subforum at this early date, when this is literally the one and only thread on the three existing ones.
Let's see what our oh-so-competent friend José has in store for us before suggesting improvements.I suspect that if Metro/etc. is a hot enough topic, for long enough, it could eventually earn a dedicated section. Until then, there's plenty of wide open space here, and an excellent host to guide us. -- Eric Last edited by Eric Pearson; Feb 9th, 2012 at 03:26 PM. |
|
#5
|
|||
|
|||
|
Contrarily to Automation, low-level COM is quite similar to calling a function dynamically.
To call a function dynamically, what we do? 1. Call LoadLibrary to load a library module into the address space of the process. It successful, it increments the reference count of the library and returns an handle. 2. Call GetProcAddress to retrieve the address of the wanted function. 3. Use CALL DWORD to call he function directly and pass the parameters. 4. Call FreeLibrary to drecement the reference count. When the reference count reaches zero, the module is unloaded from the address space of the calling process and the handle is no longer valid. COM is similar, but deals with a group of functions (called methods), and this agroupation is called an interface. Several interfaces can be grouped in a class. 1. Instead of calling LoadLibrary, we call CoCreateInstance (or the PB NEWCOM statement, that calls CoCreateInstance). CoCreateInstance calls LoadLibrary to load a library module into the address space of the process, but instead of returning the handle, it calls the CreateInstance method of an interface called IClassFactory, implemented in the COM server, and returns the address of a pointer (COM uses double indirection) to an array of DWORDs containing the addresses of all the methods that belong to the requested interface. This has a similar effect to what GetProcAdress does, but for a group of methods instead of a single function. 2. We use CALL DWORD to call the method, but as what we have is the address of a pointer to an array of pointers, instead of CALL DWORD pAdress, we have to use CALL DWORD @@pAdress[offset], where the offset is 0 for the first method, 4 for the second, 8 for the third and so on. Another particularity is that the first parameter passed is always this address to a pointer to the array of pointers, commonly know as pthis. To make it easier to use, instead of CALL DWORD @@pAdress[offset] USING <prototype declaration> <pthis, parameters>, we group the prototypes in an interface declaration and the compiler calculates the correct offset based on it. This allows to use pInterface.MethodName(parameters) instead of the more convoluted CALL DWORD @@pAdress[offset] USING <prototype declaration> <pthis, parameters>, but it does the same thing. 3. Instead of FreeLibrary, you set pInterface = NOTHING. Events work as callback functions, but instead of passing a pointer to a single function, we group several related ones in a class and we pass a reference to this class. The most important interface is IUnknown (all interfaces inherit ultimately from it), which has three methods: AddRef and Release to manage reference counting, and QueryInterface to navigate between the different interfaces implemented in the same class. You will see them being constantly used in C and other languages, but you don't need to call them with PB because it does it under the hood. However, it is important to know what they do.
__________________
Website: http://www.jose.it-berater.org/index.html SED Editor, TypeLib Browser. Forum: http://www.jose.it-berater.org/smfforum/index.php Last edited by José Roca; Feb 9th, 2012 at 07:36 PM. |
|
#6
|
|||
|
|||
|
That's an excellent description José, compliments.
|
|
#7
|
|||
|
|||
|
José--
I would like also to say thank you, for these descriptions helping us to understand how low level COM works.
__________________
Patrice Terrier pterrier@zapsolution.com www.zapsolution.com Addons: GDImage (advanced graphic control), WinLIFT (Skin Engine), Artwork (logo creation). |
|
#8
|
|||
|
|||
|
I too have learned a great deal already! Thanks José !
|
|
#9
|
|||
|
|||
|
If I had talent for writing, I could have written a book of 1,950 pages and you wouldn't have understood anything and got the wrong impresion that low-level COM is a pain to learn, when in fact is pretty straightforward.
If you look at the declaration of a METHOD, you will see that it is the same that the one for a standard function: Code:
METHOD GetBindOptions ( _ ' VTable offset = 28 BYREF pbindopts AS BIND_OPTS _ ' __in BIND_OPTS * pbindopts ) AS LONG ' HRESULT Code:
HRESULT STDMETHODCALLTYPE GetBindOptions(
/* [out][in] */ BIND_OPTS *pbindopts)
Anybody that already knows how to use the Windows API has much of the way traveled.
__________________
Website: http://www.jose.it-berater.org/index.html SED Editor, TypeLib Browser. Forum: http://www.jose.it-berater.org/smfforum/index.php |
|
#10
|
|||
|
|||
|
Quote:
And the include set that is up is taken. I found myself doing that quite often, trying which include set was the right for an old project. Therefore what I would prefer is not a change in the IDE but a Meta-statement in the compiler to override the IDE.Setting, like the one in CSED. As its the compiler that uses the "Include Path" at the end, thsource code is the right place where it should be, Code:
$CSED_INCPATH = "E:\...\pbwin10\WINAPI_IV" If the setting are in the IDE, how will you know in several years, when the next PB is on the market, which set of includes the old project has used?
__________________
--Theo Gottwald ------------------------------------------------ 76706 Dettenheim * Germany * info@it-berater.org ------------------------------------------------ Joses Forum * Theo's Link Site * IT-Berater.org Last edited by Theo Gottwald; Feb 18th, 2012 at 09:48 AM. |
|
#11
|
|||
|
|||
|
I've been watching this thread for a while, it's useful to me since I'm only a beginner in this subject - it helps me learn and figure everything out. Thanks for sharing your expertise, guys!
__________________
m4a to mp3 converter |
|
#12
|
|||
|
|||
|
I've been trying COM for a while now. Mainly by stealing Jose's code and modifying to suit. I really appreciate all of the guidance that he and others are willing to provide. The learning curve on COM seems a little steeper than most technologies. Just have to keep pushing.
__________________
Rick |
![]() |
| Thread Tools | |
| Display Modes | |
|
|