mirror of
https://github.com/SSCLI/sscli_20021101
synced 2026-06-08 12:28:57 +00:00
9fa3874800
Moved the original file to the archive subfolder.
84 lines
2.4 KiB
HTML
84 lines
2.4 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
|
<html>
|
|
<head>
|
|
<title>Tk Wrapper Sample</title>
|
|
<link rel="stylesheet" type="text/css" href="../../../docs/rotor.css">
|
|
</head>
|
|
|
|
<body>
|
|
|
|
|
|
<h1> Tk Wrapper Sample</h1>
|
|
|
|
|
|
<h2>Sample Overview</h2>
|
|
|
|
|
|
<p>This sample assembly illustrates wrapping a dynamic link library (DLL) implemented
|
|
in C. It also allows access to some rudimentary user interface functionality
|
|
across platforms.</p>
|
|
|
|
<h2>Sample Source and Build Output Locations</h2>
|
|
|
|
|
|
<p>The sample source is found in sscli\samples\pigui\tk.</p>
|
|
|
|
|
|
<p>The sources files are:</p>
|
|
|
|
|
|
<ul class="none">
|
|
<li><a href="callconvattribute.cs">callconvattribute.cs</a></li>
|
|
<li><a href="delegatewrappers.cs">delegatewrappers.cs</a></li>
|
|
<li><a href="tclnative.cs">tclnative.cs</a></li>
|
|
<li><a href="tk.cs">tk.cs</a></li>
|
|
<li><a href="tknative.cs">tknative.cs</a></li>
|
|
</ul>
|
|
|
|
|
|
<p>Due to a limitation in the way delegates interact with platform invoke,
|
|
C-implemented APIs that use the cdecl calling convention and require callbacks
|
|
are not supported in C#. This sample illustrates a way to resolve this issue. It uses a custom attribute to annotate the desired interop
|
|
delegate declarations. The C# code is then compiled into an assembly.
|
|
That assembly is then disassembled into CIL using the CIL Disassembler tool. This
|
|
CIL text is then parsed using the custom attribute as a tag for modification by
|
|
the Perl script in:</p>
|
|
<blockquote>
|
|
<p><a href="callconvhack.pl">callconvhack.pl</a></p>
|
|
</blockquote>
|
|
<p>The modified CIL is then recompiled into an assembly using the CIL Assembler tool.</p>
|
|
|
|
|
|
<p>The build output location is %TARGETCOMPLUS%\samples\pigui.
|
|
The output file is an assembly named sharedsourcecli.tk.dll.</p>
|
|
|
|
|
|
<h2>Building the Sample</h2>
|
|
|
|
|
|
<p>All samples are built from the buildall script. </p>
|
|
|
|
|
|
<p>You can also build all the
|
|
samples by switching to the root of the sample directory, sscli\samples, and typing
|
|
<code>build -c</code>.</p>
|
|
|
|
|
|
<p>You can build this specific sample by switching to the sample directory and typing
|
|
<code>build -c</code>.</p>
|
|
|
|
|
|
<h2>Running the Sample</h2>
|
|
|
|
|
|
<p>This sample creates an assembly that is used by the
|
|
<a href="../hello/hello.html">PIGUI Hello sample</a> and
|
|
the <a href="../pigpad/pigpad.html">pigpad sample</a>.</p>
|
|
|
|
|
|
<hr>
|
|
|
|
|
|
<p><i>Copyright (c) 2002 Microsoft Corporation. All rights reserved.</i></p>
|
|
</body>
|
|
</html> |