和在VB等语言中实现方式一样,调用Windows API.
using
System;
using
System.Windows.Forms;
using
System.Runtime.InteropServices;
![None.gif](/Images/OutliningIndicators/None.gif)
![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
namespace
Jacky.Win32API
{
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
/// Show Windows About Box
/// </summary>
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
public class AboutBox
{
[DllImport("shell32.dll")]
private static extern long ShellAbout(int hWnd, string szApp, string szOtherStuff, int hIcon);
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
private string _Title = Application.ProductName;
private int _FormHandle = 0;
private int _IconHandle = 0;
private string _Version = Application.ProductVersion;
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
///
/// </summary>
/// <param name="FormHandle"></param>
/// <param name="IconHandle"></param>
/// <param name="Title"></param>
/// <param name="Version"></param>
/// <example>new AboutBox(this.Handle.ToInt32(), this.Icon.Handle.ToInt32(), "软件名称", "版本号Version 1.0").Show();</example>
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
public AboutBox(int FormHandle, int IconHandle, string Title, string Version)
{
this._FormHandle = FormHandle;
this._IconHandle = IconHandle;
this._Title = Title;
this._Version = Version;
}
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
/**//// <summary>
///
/// </summary>
/// <param name="FormHandle"></param>
/// <param name="IconHandle"></param>
/// <example>new AboutBox(this.Handle.ToInt32(), this.Icon.Handle.ToInt32(), "软件名称", "版本号Version 1.0").Show();</example>
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
public AboutBox(int FormHandle, int IconHandle)
{
this._FormHandle = FormHandle;
this._IconHandle = IconHandle;
}
![InBlock.gif](/Images/OutliningIndicators/InBlock.gif)
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
public long Show()
{
return ShellAbout(this._FormHandle, this._Title, this._Version, this._IconHandle);
}
}
}
调用方式:
new
AboutBox(
this
.Handle.ToInt32(),
this
.Icon.Handle.ToInt32(),
"
软件名称
"
,
"
版本号Version 1.0
"
).Show();