⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmlogs.cs

📁 清华大学出版社出版的 移动应用开发宝典 张大威(2008)的附书源代码
💻 CS
字号:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using CodeForChapter4cs_DLL;

namespace CodeForChapter4cs
{
  public partial class frmLogs : Form
  {
    public frmLogs()
    {
      InitializeComponent();
      this.Text = System.Net.Dns.GetHostName();
    }

    [DllImport("ws22.dll", SetLastError = true)]
    public static extern Int32 sethostname(byte[] pName, Int32 cName);

    [DllImport("ws2.dll", SetLastError = true)]
    public static extern Int32 sethostnamee(byte[] pName, Int32 cName);
		

    private void menuItem1_Click(object sender, EventArgs e)
    {
      byte[] b = ASCIIEncoding.ASCII.GetBytes("my dev name" + "\0");
      try
      {
      sethostnamee(b, b.GetLength(0));

      }
      catch (Exception ex)
      {

        MessageBox.Show(ex.Message); 
      }
     // sethostname(b, b.GetLength(0));

      if (sethostname(b, b.GetLength(0)) == 0)
      {
        this.Text = System.Net.Dns.GetHostName();
      }
      else
      {
        this.Text = Marshal.GetLastWin32Error().ToString();
      }

    }

    private void menuItem2_Click(object sender, EventArgs e)
    {
      Marshal.PrelinkAll(this.GetType());
      SomeClass s = new SomeClass();
    }
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -