如何DllImport 一个DLL?

rockmanhqu 2007-06-25 10:45:48
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;

namespace DLL
{
public class UserPowerDll
{
[DllImport("CDSkey.dll", CharSet = CharSet.Auto)]
public static extern bool GetSysPower; //报错修饰“extern”对该项无效?为什么会报这个错误呀。
}
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
if (UserPowerDll.GetSysPower)
{ MessageBox("Yes"); }
else { MessageBox("No"); }
}
}
}
如上代码:extern 报错。
...全文
210 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
bote_china 2007-06-25
  • 打赏
  • 举报
回复
[DllImport("CDSkey.dll", CharSet = CharSet.Auto)]
public static extern bool GetSysPower();
xyq1986 2007-06-25
  • 打赏
  • 举报
回复
参数也要出来吧

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧