Pelles C forum

C language => User contributions => Topic started by: frankie on November 09, 2023, 03:21:27 PM

Title: Toast Notifications demo in plain C
Post by: frankie on November 09, 2023, 03:21:27 PM
If you're not hungry, but want taste windows toast notifications...  ;D
Title: Re: Toast Notifications demo in plain C
Post by: MrBcx on November 09, 2023, 04:00:02 PM
Excellent demo Frankie!

It boggles the mind why MS makes some things so damn difficult to use.

Thank you for sharing this.
Title: Re: Toast Notifications demo in plain C
Post by: Vortex on November 09, 2023, 07:12:04 PM
Hi Frankie,

Thanks for your efforts. The executable does not run on Windows 7 64-bit :

Code: [Select]
\PellesC\bin\podump.exe /IMPORTS ToastDemo.exe | findstr ".dll"
Code: [Select]
        KERNEL32.dll
        ADVAPI32.dll
        USER32.dll
        ole32.dll
        api-ms-win-core-winrt-l1-1-0.dll
        api-ms-win-core-winrt-string-l1-1-0.dll

The last two DLLs are missing on my system.

Installing the Update for Universal C Runtime ( Windows 7 ) didn't help.

https://github.com/dotnet/core/issues/6976
Title: Re: Toast Notifications demo in plain C
Post by: TimoVJL on November 10, 2023, 08:36:37 AM
Testing Win 7 and using missing dlls
Code: [Select]
Second chance exception 0xC0000005 (Access Violation) occurred in "TOASTDEMO.EXE" at address 0x000000013FEB160C.
Code: [Select]
22.08.2013  13:45             4 096 api-ms-win-core-threadpool-l1-1-0.dll
22.08.2013  13:42             3 584 api-ms-win-core-winrt-error-l1-1-0.dll
22.08.2013  13:42             3 584 api-ms-win-core-winrt-l1-1-0.dll
22.08.2013  13:42             3 072 api-ms-win-core-winrt-robuffer-l1-1-0.dll
22.08.2013  13:42             4 096 api-ms-win-core-winrt-string-l1-1-0.dll
here it crash:
Code: [Select]
if (!SUCCEEDED(RoGetActivationFactory(hsToastNotificationManager, &IID_IToastNotificationManagerStatics, (LPVOID*)&pToastNotificationManager)))
return 1;
Better to do this:
Code: [Select]
if (!SUCCEEDED(RoGetActivationFactory(hsToastNotificationManager, &IID_IToastNotificationManagerStatics, (LPVOID*)&pToastNotificationManager)))
return 1;
if (!pToastNotificationManager)
return 2;
Title: Re: Toast Notifications demo in plain C
Post by: Vortex on November 10, 2023, 10:11:32 AM
Hello,

On a Windows 11 system, the application works fine. Testing on a Windows 10 computer, I can only type 1 line as the Enter key has no any effect.
Title: Re: Toast Notifications demo in plain C
Post by: John Z on November 10, 2023, 10:48:30 AM
Hi all,

Well my Win 7 Home Premium with service pack 1 also has the missing dll issue. 
api-ms-win-core-winrt-l1-1-0.dll   (maybe more but stops here)

I searched the web it seems a very common lament about Win 7. 
I did not find any site deemed safe enough to try to download.

Win 11 as with everyone else works great, but leaves a console window open (maybe on purpose?)

John Z
Title: Re: Toast Notifications demo in plain C
Post by: TimoVJL on November 10, 2023, 12:16:43 PM
This didn't help.
runtime.win7-x64.Microsoft.NETCore.Windows.ApiSets (https://www.nuget.org/packages/runtime.win7-x64.Microsoft.NETCore.Windows.ApiSets)
Code: [Select]
Loaded "RPCRTREMOTE.DLL" at address 0x000007FEFCC00000.  Successfully hooked module.
DllMain(0x000007FEFCC00000, DLL_PROCESS_ATTACH, 0x0000000000000000) in "RPCRTREMOTE.DLL" called.
DllMain(0x000007FEFCC00000, DLL_PROCESS_ATTACH, 0x0000000000000000) in "RPCRTREMOTE.DLL" returned 1 (0x1).
Second chance exception 0xC0000005 (Access Violation) occurred in "TOASTDEMO.EXE" at address 0x000000013F11160C.
Exited "TOASTDEMO.EXE" (process 0x27E8) with code -1073741819 (0xC0000005).
Code: [Select]
13.06.2016  21:46            19 704 api-ms-win-core-winrt-l1-1-0.dll
13.06.2016  21:46            20 240 api-ms-win-core-winrt-string-l1-1-0.dll
13.06.2016  21:46            19 728 api-ms-win-core-winrt-error-l1-1-0.dll
13.06.2016  21:46            19 224 api-ms-win-core-winrt-robuffer-l1-1-0.dll
13.06.2016  21:46            19 240 api-ms-win-core-threadpool-l1-1-0.dll
EDIT: can't work with stub dlls and code don't check actual pointers
Title: Re: Toast Notifications demo in plain C
Post by: frankie on November 10, 2023, 12:44:39 PM
Hi Frankie,

Thanks for your efforts. The executable does not run on Windows 7 64-bit :

Code: [Select]
\PellesC\bin\podump.exe /IMPORTS ToastDemo.exe | findstr ".dll"
Code: [Select]
        KERNEL32.dll
        ADVAPI32.dll
        USER32.dll
        ole32.dll
        api-ms-win-core-winrt-l1-1-0.dll
        api-ms-win-core-winrt-string-l1-1-0.dll

The last two DLLs are missing on my system.

Installing the Update for Universal C Runtime ( Windows 7 ) didn't help.

https://github.com/dotnet/core/issues/6976
It seems that the problem is bigger, because the changes in the framework are incompatible (seems a Python issue ?).
Anyway a solution has been crafted to allow Blender to run on WIN7. You can find it on github (https://github.com/nalexandru/api-ms-win-core-path-HACK).
Let me know if it works.

Hi all,

Well my Win 7 Home Premium with service pack 1 also has the missing dll issue. 
api-ms-win-core-winrt-l1-1-0.dll   (maybe more but stops here)

I searched the web it seems a very common lament about Win 7. 
I did not find any site deemed safe enough to try to download.

Win 11 as with everyone else works great, but leaves a console window open (maybe on purpose?)

John Z
Yes John the code let the console running, for what purpose I don't know. It was the original demo that I already modified, I have to haircut it a bit more... ;D

EDIT: Added compiled DLL for X86 and X64.
Title: Re: Toast Notifications demo in plain C
Post by: Vortex on November 10, 2023, 07:42:05 PM
Hi Frankie,

Thanks for your help. Your zip attachment contains the file api-ms-win-core-path-l1-1-0 but the ToastDemo.exe is asking for api-ms-win-core-winrt-l1-1-0.dll ( later probably the DLL api-ms-win-core-winrt-string-l1-1-0.dll )

Title: Re: Toast Notifications demo in plain C
Post by: frankie on November 11, 2023, 04:13:42 PM
Hi Frankie,

Thanks for your help. Your zip attachment contains the file api-ms-win-core-path-l1-1-0 but the ToastDemo.exe is asking for api-ms-win-core-winrt-l1-1-0.dll ( later probably the DLL api-ms-win-core-winrt-string-l1-1-0.dll )
Hi Erol,
I made a mistake  ;D
Confused names  ::)
Anyway seems that there isn't solution for this problem of missing dll under win7.
The functions in the library are in different libraries. The work to do is to remove the library "runtimeobject.lib", and add to the linker the "api-ms-win-core-winrt-*.dll" libraries present on the WIN7 system containing the same functions present in "runtimeobject.lib".
Honestly I'm not intrigued by revitalizing WIN7, Now I'm more attracted with the toast notifications thing.
You can make some trials, and to help on this I attach the definition file of "runtimeobject.lib", 64 bits version, to identify the required functions.
Title: Re: Toast Notifications demo in plain C
Post by: Vortex on November 12, 2023, 05:38:16 PM
Hi Frankies,

Thanks, no worries. Sadly, M$ is deliberately complicating a lot of things. :(
Title: Re: Toast Notifications demo in plain C
Post by: frankie on November 21, 2023, 12:12:50 AM
Excellent demo Frankie!

It boggles the mind why MS makes some things so damn difficult to use.

Thank you for sharing this.
Yes this thing is so damned difficult, but very very flexible and powerful indeed  :D.
So to make things simpler you may want try my toast library (https://forum.pellesc.de/index.php?topic=11036.msg38700#msg38700) on github (https://github.com/Frankie-PellesC/ToastLib/tree/main).  ;D