-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a314156
Showing
5 changed files
with
187 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
################### | ||
# compiled source # | ||
################### | ||
*.com | ||
*.class | ||
*.dll | ||
*.exe | ||
*.pdb | ||
*.dll.config | ||
*.cache | ||
*.suo | ||
# Include dlls if they’re in the NuGet packages directory | ||
!/packages/*/lib/*.dll | ||
!/packages/*/lib/*/*.dll | ||
# Include dlls if they're in the CommonReferences directory | ||
!*CommonReferences/*.dll | ||
#################### | ||
# VS Upgrade stuff # | ||
#################### | ||
UpgradeLog.XML | ||
_UpgradeReport_Files/ | ||
############### | ||
# Directories # | ||
############### | ||
bin/ | ||
obj/ | ||
TestResults/ | ||
################### | ||
# Web publish log # | ||
################### | ||
*.Publish.xml | ||
############# | ||
# Resharper # | ||
############# | ||
/_ReSharper.* | ||
*.ReSharper.* | ||
############ | ||
# Packages # | ||
############ | ||
# it’s better to unpack these files and commit the raw source | ||
# git has its own built in compression methods | ||
*.7z | ||
*.dmg | ||
*.gz | ||
*.iso | ||
*.jar | ||
*.rar | ||
*.tar | ||
*.zip | ||
###################### | ||
# Logs and databases # | ||
###################### | ||
*.log | ||
*.sqlite | ||
# OS generated files # | ||
###################### | ||
.DS_Store? | ||
ehthumbs.db | ||
Icon? | ||
Thumbs.db | ||
[Bb]in | ||
[Oo]bj | ||
[Tt]est[Rr]esults | ||
*.suo | ||
*.user | ||
*.[Cc]ache | ||
*[Rr]esharper* | ||
packages | ||
NuGet.exe | ||
_[Ss]cripts | ||
*.exe | ||
*.dll | ||
*.nupkg | ||
*.ncrunchsolution | ||
*.dot[Cc]over | ||
**/PublishProfiles | ||
.vs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.4.33020.496 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GuidClip", "GuidClip\GuidClip.csproj", "{27BFC1B3-1F54-4D6A-A958-0010A6211E9A}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{27BFC1B3-1F54-4D6A-A958-0010A6211E9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{27BFC1B3-1F54-4D6A-A958-0010A6211E9A}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{27BFC1B3-1F54-4D6A-A958-0010A6211E9A}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{27BFC1B3-1F54-4D6A-A958-0010A6211E9A}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
GlobalSection(ExtensibilityGlobals) = postSolution | ||
SolutionGuid = {6DE80377-8A93-4130-BB8D-ED49896C72C9} | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<OutputType>WinExe</OutputType> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks> | ||
<PublishAot>true</PublishAot> | ||
<InvariantGlobalization>true</InvariantGlobalization> | ||
<IlcGenerateStackTraceData>false</IlcGenerateStackTraceData> | ||
<IlcDisableReflection>true</IlcDisableReflection> | ||
<IlcOptimizationPreference>Size</IlcOptimizationPreference> | ||
<IlcFoldIdenticalMethodBodies>true</IlcFoldIdenticalMethodBodies> | ||
<IlcTrimMetadata>true</IlcTrimMetadata> | ||
<IlcInvariantGlobalization>true</IlcInvariantGlobalization> | ||
<IlcGenerateCompleteTypeMetadata>false</IlcGenerateCompleteTypeMetadata> | ||
<GenerateRuntimeConfigurationFiles>false</GenerateRuntimeConfigurationFiles> | ||
<DebugType>none</DebugType> | ||
<DebuggerSupport>false</DebuggerSupport> | ||
<EnableUnsafeBinaryFormatterSerialization>false</EnableUnsafeBinaryFormatterSerialization> | ||
<EnableUnsafeUTF7Encoding>false</EnableUnsafeUTF7Encoding> | ||
<EventSourceSupport>false</EventSourceSupport> | ||
<HttpActivityPropagationSupport>false</HttpActivityPropagationSupport> | ||
<UseSystemResourceKeys>true</UseSystemResourceKeys> | ||
<IlcGenerateMapFile>false</IlcGenerateMapFile> | ||
<IlcGenerateMetadataLog>false</IlcGenerateMetadataLog> | ||
<IlcGenerateDgmlFile>false</IlcGenerateDgmlFile> | ||
</PropertyGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System.Diagnostics; | ||
using System.Runtime.InteropServices; | ||
using System.Text; | ||
using GuidClip; | ||
|
||
const int CF_UNICODETEXT = 0x0D; | ||
|
||
unsafe | ||
{ | ||
var buffer = (byte*)NativeMemory.Alloc(32 * 2 + 2); | ||
|
||
var bytesWritten = Encoding.Unicode.GetBytes( | ||
chars: Guid.NewGuid().ToString(), | ||
bytes: new Span<byte>(buffer, 36 * 2)); | ||
|
||
Debug.Assert(bytesWritten is 36 * 2); | ||
|
||
buffer[72] = 0; // Null Terminator | ||
buffer[73] = 0; // Null Terminator | ||
|
||
var result = SafeNativeMethods.OpenClipboard(IntPtr.Zero); | ||
Debug.Assert(result); | ||
|
||
result = SafeNativeMethods.EmptyClipboard(); | ||
Debug.Assert(result); | ||
|
||
SafeNativeMethods.SetClipboardData(CF_UNICODETEXT, buffer); | ||
|
||
result = SafeNativeMethods.CloseClipboard(); | ||
Debug.Assert(result); | ||
|
||
NativeMemory.Free(buffer); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
namespace GuidClip; | ||
|
||
using System.Runtime.InteropServices; | ||
|
||
public static unsafe partial class SafeNativeMethods | ||
{ | ||
[return: MarshalAs(UnmanagedType.Bool)] | ||
[LibraryImport("user32.dll", SetLastError = true)] | ||
public static partial bool CloseClipboard(); | ||
|
||
[LibraryImport("user32.dll")] | ||
[return: MarshalAs(UnmanagedType.Bool)] | ||
public static partial bool EmptyClipboard(); | ||
|
||
[return: MarshalAs(UnmanagedType.Bool)] | ||
[LibraryImport("user32.dll", SetLastError = true)] | ||
public static partial bool OpenClipboard(IntPtr hWndNewOwner); | ||
|
||
[LibraryImport("user32.dll")] | ||
public static partial IntPtr SetClipboardData(uint uFormat, byte* memory); | ||
} |