Skip to content

Instantly share code, notes, and snippets.

@SelvinPL
Created January 26, 2023 20:25
Show Gist options
  • Select an option

  • Save SelvinPL/0c2c1be7448646293a7d9d3b441cee96 to your computer and use it in GitHub Desktop.

Select an option

Save SelvinPL/0c2c1be7448646293a7d9d3b441cee96 to your computer and use it in GitHub Desktop.
SO75244656
using System.Runtime.InteropServices;
using System;
using System.Windows.Forms;
// this guy stolen my code without credits https://www.codeproject.com/Articles/16310/How-to-Automate-Exporting-NET-Function-to-Unmanage
using RGiesecke.DllExport;
//<Project Sdk="Microsoft.NET.Sdk">
// <PropertyGroup>
// <TargetFramework>net48</TargetFramework>
// <PlatformTarget>x86</PlatformTarget>
// </PropertyGroup>
// <ItemGroup>
// <PackageReference Include="UnmanagedExports.Repack.Upgrade" Version="1.2.1" />
// </ItemGroup>
// <ItemGroup>
// <Reference Include="System.Windows.Forms" />
// </ItemGroup>
//</Project>
namespace Rundll32Test
{
public static class NativeEntry
{
[DllExport("Test", CallingConvention = CallingConvention.StdCall)]
public static void Test(IntPtr hwnd, IntPtr hinst, string cmdLine, int cmdShow)
{
MessageBox.Show(string.Format("HWND: {0}, HINST: {1}, CDMDSHOW: {3}\n{2}", hwnd, hinst, cmdLine, cmdShow));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment