How to access the GetDoubleClickTime Win32 API function from a WinUI 3.0 Runtime Component library - c++-winrt

I'm trying to call the GetDoubleClickTime Win32 API function using C++ from a new project created with the "Windows Runtime Component (WinUI 3)" Visual Studio template.
To do so, I'm adding #include <Windows.h> to the pch.h file and then simply call the mentioned function. However, I'm getting the following compiler error afterwards: error C3861: 'GetDoubleClickTime': identifier not found.
According to the template description, this project should create a library that is both usable in Desktop and UWP apps. I'm aware that the GetDoubleClickTime function cannot be called from UWP. But it has to work for Desktop apps.
How can I make this work?

Apparently it creates a sandboxed UWP project behind the scenes. Please refer to this GitHub issue and see #sylveon's comments at the very bottom of the conversation for a potential fix/workaorund.
You can edit the vcxproj's global PropertyGroup and add these two directives right now to force the UWP project to use the desktop API set, and link the desktop CRT (removing the need to carry around the VCRT forwarders, which are honestly a terrible hack)
<_NoWinAPIFamilyApp>true</_NoWinAPIFamilyApp>
<_VC_Target_Library_Platform>Desktop</_VC_Target_Library_Platform>
Alternatively, it seems that merely setting <AppContainerApplication>false</AppContainerApplication> works as well.

Related

How to consume WinRT component inside Win32 dll project?

Using Registration-free WinRT it is possible to load WinRT components inside Win32 application.
What's the process to load WinRT component from inside Win32 dll? I tried the steps mentioned as part of Win32, but winmd files are not generating the corresponding header files.
Main usage scenario is dll can be loaded any application, like electron node addon or c# app etc.,
Without any changes to application, dll by itself should be able to consume WinRT component!
Did you add a reference to the WinMD file in the vcxproj and then installed the C++/WinRT NuGet package? This should make it generate the corresponding header files that your DLL project can then consume.
Following is the solution:
Was able to fix this in weird manner i.e. not a standard way to solve this.
Our use case was to use FFmpegInteropX inside win32 dll, so that we can use ffmpeg as a source reader and use the underlying hardware decode support. Mechanism is discussed detailly in the following link:
https://github.com/ffmpeginteropx/FFmpegInteropX/discussions/275#discussioncomment-3091100
Following changes were done to use WinRT component inside a Win32 dll:
Copied the WinRT generated files from the application to Win32 dll project
Before invoking any of the api from the generated runtime class, did LoadLibrary of the specific WinRT component into the dll
Now the make the necessary WinRT component call as it was done in standard win32 application
All modules were working as expected.
Above solution was copied from:
https://learn.microsoft.com/en-us/answers/questions/924996/how-to-consume-winrt-component-inside-win32-dll-pr.html
It's not a straight forward solution, also not sure if MS has any plans to add support for WinRT component inside dll project, if such support comes up then this may not be needed.

How to embed a VCL component in a dll and use it in a VCL application?

I have created a DLL that are using VCL components in its code. The DLL is hiding all C++ code behind a C API.
Using the DLL works fine in a console application.
However, when trying to use it in a regular VCL forms application, I get errors when any code is trying to view VCL frames or forms, e.g.
I suspect this has todo with linking in the VCL into the DLL.
Question is, do one have to prepare the creation of a DLL using VCL components in some way to avoid this problem? I think it has todo with HINSTANCE somehow?
The reason for creating the DLL in the first place, is to be able to provide a pure C API, so that the code can be used with other compilers, e.g. Visual studio. I would use a package otherwise.

Xamarin Forms code sharing

I'm working on a xamarin forms (PCL) project (A basic customer care chat app which is meant to run on Android and iOS only) that has just two xaml pages, custom renderers and few dependencies. This project is meant to be implemented into another existing project (which I don't have access to its source code) such that an action would be binded to a button on the existing app to show a page on my own project.
There is need for me to share my chat project with my client's developer but without exposing my source codes, perhaps compiling to dll or nuget package that would be added to the existing project to access my project's functions and pages. I have searched through the xamarin forum and here on stackoverflow but can't seem to lay my hands on a solution.
Is this possible at all? If yes, what am I missing? If no, is there any better option to use?
Please do note that the chat app completely done, so I'm hoping perhaps there's a way I could directly convert the project to a Nuget package.
Thanks in anticipation!
If the host application is a Xamarin Forms one:
-Move your cross platform shared code into a PCL or .Net Standard (ContentPages, ContentViews, Classes).
-Move your Renderers and platform specific code to Android and iOs Class Libraries.
Your client will have to reference your first assembly (dll) in their XF assembly in order to instantiate/manipulate your views/classes and platform specifics one on their Back-end side (taking into account your renderers, effects, etc ...)
A lot of Xamarin Controls Libraries Open Source hosted on Github are working like that. For example this one: https://github.com/jamesmontemagno/Xamarin.Forms-PullToRefreshLayout
If the host application is a native application, take a look into Xamarin forms embedding
Finally, I seem to solve the problem by enabling visual studio to build Nuget packages for the chat app project (summing up to 3 nuget packages) on project build.
Thanks #Rudy Spano and #Micah Switzer for your contributions

VB.NET External control - Need to include with setup?

I developed a new label control and compiled it into a DLL which I am using in one of my other apps. The problem is, the app fails to launch in the target environment if I don't include the label control's DLL with the setup and install it in the same directory as the app.
I am trying to understand why this is. I thought with VB.NET we no longer have to include individual DLLs if we reference and build the app with it. I tried looking for answers elsewhere but the information is patchy to me.
Any help would be highly appreciated.

FileNotFoundException when referencing (managed) C++ Assembly from a C# Console App

I am in the process of writing a .NET wrapper for legacy native c++ code. My strategy is to write a CLR class library that wraps the native code.
To test whether the class library is functioning properly, I created two console apps in separate solutions:
A C++ CLR console app
A C# console app
Both of these contain the same simple test code to exercise the class library.
Both apps build as expected. The C++ app runs just fine, but the C# app is giving me a FileNotFoundException when it tries to load my class library.
I have a constraint that forces me to use VS2008 and .NET 3.5. Everything is built with Win32 or x86 configurations.
For both console apps, I am using a project reference to the class library.
In each case, builds copy the dll (and the intermediate files) to the same directory where each app is built.
I tried using the fusion log viewer, but logs are disabled on my machine and I do not have administrator privileges.
Has anyone ever seen this before?
Can someone please point me to a good site that outlines the differences between the way C# and C++ CLR apps load assemblies?
Since this is my first attempt to bridge C++ and C# I assume I am just making a simple mistake somewhere, but I am stumped as to what that is.
I have trolled the internet (including many SO postings) but have yet to find exactly what I need.
Thanks in advance,
Judd