Jacky sun

Good Good Study, Day Day Up!!!

 

在自己的应用程序中显示Windows关于对话框

和在VB等语言中实现方式一样,调用Windows API.
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace Jacky.Win32API {
    
/// <summary>
    
/// Show Windows About Box
    
/// </summary>

    public class AboutBox {
        [DllImport(
"shell32.dll")]
        
private static extern long ShellAbout(int hWnd, string szApp, string szOtherStuff, int hIcon);

        
private string _Title = Application.ProductName;
        
private int   _FormHandle = 0;
        
private int   _IconHandle = 0;
        
private string _Version   = Application.ProductVersion;

        
/// <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>

        public AboutBox(int FormHandle, int IconHandle, string Title, string Version) {
            
this._FormHandle = FormHandle;
            
this._IconHandle = IconHandle;
            
this._Title         = Title;
            
this._Version     = Version;
        }


        
/// <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>

        public AboutBox(int FormHandle, int IconHandle) {
            
this._FormHandle = FormHandle;
            
this._IconHandle = IconHandle;
        }


        
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();

posted on 2004-08-29 11:17  jacky  阅读(1659)  评论(0编辑  收藏  举报

导航