Re: COM objects and instance creation in Lispworks
Martin Simmons <[email protected]>
| Newsgroups | gmane.lisp.lispworks.general |
|---|---|
| Message-ID | <[email protected]> |
The first thing you need to do is generate FLI definitions from the .idl files
(not from the .h files). See
https://www.lispworks.com/documentation/lw81/com/com-com-using-2.htm#1.2.2%20Generating%20FLI%20definitions%20from%20COM%20definitions-2
Microsoft provides these .idl files in this case (probably as part of the
Windows SDK):
IMMDeviceEnumerator is in mmdeviceapi.idl
IAudioSessionManager and IAudioSessionNotification are in audiopolicy.idl
I assume that you don't have to implement IMMDeviceEnumerator etc -- they are
implemented by Microsoft, so you just need to call their implementations. You
will need to implement IAudioSessionNotification with
define-com-implementation.
There is an example of implementing and calling COM methods here:
https://www.lispworks.com/documentation/lw81/com/com-examples-ug-1.htm
The example just calls the methods in args-calling.lisp that it implements in
args-impl.lisp, but the same approach using com:call-com-interface works for
methods implemented by someone else.
The example contains args.idl, but :type :midl-file in defsystem can also be
used with files from the Windows SDK. It should detect the path of the SDK
automatically (see "Import paths" in
https://www.lispworks.com/documentation/lw81/com/com-com-ref-34.htm).
--
Martin Simmons
LispWorks Ltd
http://www.lispworks.com/
>>>>> On Tue, 04 Nov 2025 23:25:47 +0100, david (as david at bundgaard dot se) said:
>
> Hello all,
> I am fairly new to Lispworks.
> I am trying to grok the COM library.
> In this case, I want to build an audio session monitoring for Windows, which to requires me to implement the IAudioSessionNotification in Lisp.
>
> The interface is fairly simple
>
> MIDL_INTERFACE("641DD20B-4D41-49CC-ABA3-174B9477BB08")
>
> IAudioSessionNotification : public IUnknown
>
> {
>
> public:
> virtual HRESULT STDMETHODCALLTYPE OnSessionCreated(
> /* [in] */ IAudioSessionControl *NewSession) = 0;
>
> };
>
> To get access to use this event, I need to instantiate IMMDeviceEnumerator, from there we go get the GetDefaultEndpoint(eRender, eConsole, &device).
>
> Then we do some more magic, the process is the same, and we end up with an IAudioSessionManager, with which we can register our callback class (IAudioSessionNotification).
>
> Do I need to replicate all the methods and types to be able to call the various methods on each COM class?
>
> I started by creating a .idl file, that would mirror the IAudioSessionNotification and IAudioSessionControl.
>
> I assume I should continue creating all the types (IMMDeviceEnumerator, IMMDevice, IAudioSessionEnumerator, etc), should I also implement their interfaces (define-com-implementation).
>
> All the best
> David
>
>
_______________________________________________
Lisp Hug - the mailing list for LispWorks users
[email protected]
http://www.lispworks.com/support/lisp-hug.html