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 报错。
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 报错。
解决方案 »
- 大家看看这个小问题!
- 如何实现XML同层节点交换
- 在 System.Data.SqlClient.SqlException 中第一次偶然出现的“System.Data.dll”类型的异常
- C# Process.start()一个程序后 被启动的程序会自动退出
- 用数据集插入数据问题(不知这样问合不合适)
- 请高人指点!
- c#中函数说明遇到的问题
- SIP账号注册不上。
- 未处理的“System.ObjectDisposedException”类型的异常出现在 system.windows.forms.dll 中
- 如何在ListView控件中自动排序
- 用CVSNT配置时服务器是花生壳动态生成IP的,服务器名该怎么设?
- 那里有保罗&加芬克尔的原版《斯卡布罗集市》下载?
public static extern bool GetSysPower();