T,
Post by TBut your definition header are so easy to understand
they are almost artwork
I'm sorry, but you can't blame me of that. Thats wholly the Assembly
languages fault. :-)
I'm still willing to provide you with some data about the involved functions
though. Its just that I have a very strong feeling about keeping seperate
problems seperate, and only link their solutions together.
That doesn't mean that those solutions can't be altered, but if I think it
will be a major change I copy them into their own programs and alter and
test them there.
And to be honest, the whole thing basically is, in Assembly, about six
functions:
One to start a dialog window (a classic window needs way more) and one to
exit it.
One to terminate the program.
One to start the device-change capturing and one to stop it.
And one for the "start another program".
Its just that the first and third need quite a bit of extra data and code to
be able to function.
Ofcourse, if you want to be able to supply arguments to such a program (like
the to be started program, or an option to or hide the program from the
desktop and remove it from the taskbar) than it ofcourse needs a bit more
work. :-)
The thing is, I have absolutily /no/ idea if your language allows you to
create a GUI based program, and if so if it allows you to handle such WM_*
messages yourself. Heck, I do not even know how well it handles data
structures (which you need for both the first, third and fourth steps).
I most always use "DialogBoxParam" for my window creation (
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-dialogboxparama )
, as its generally the easiest one to use. The call itself isn't the
problem, but just take a look at the "lpTemplateName" and "lpDialogFunc"
arguments.
The first one is a structure which describes what your window looks like
(including al its elements, like buttons, text-entry boxes, etc). Creating
that structure is a challenge in itself (my Assembly environment has a
"resource compiler" for that, meaning I only have to describe the dialog
window and its contents), and than you have to put it into a resource file.
The other option is to use "DialogBoxIndirectParam" (
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-dialogboxindirectparama )
, which allows you to put that template data in the program itself (no
resource file needed).
The latter one is a pointer to a callback function which receives /all/ WM_*
messages ment for that window, and which you need to handle to make the
whole thing work. Luckily, for a dialog window you only need to handle the
WM_CLOSE message and as a result call "EndDialog" call to have it work as
expected (if you do not handle WM_CLOSE you can't dismiss the window - which
actually, in your case, might be usefull ...)
It also will, after after you called 'RegisterDeviceNotification' as a
result of receiving the WM_INITDIALOG message, receive that WM_DEVICECHANGE
message which you are interrested in.
Just first make sure you have a working dialog window, so that you /can/
receive that message. :-)
Regards,
Rudy Wieser