1、打开机床设置——进入图下界面——通过改写参数将I/O通道改为17(这一步看似简单却极为重要的环节)
2、I/O通道改写完成后,将USB设备接入机床,按机床程序键进入图1下界面,并按图中指示按键,进入图2界面
3、点击图中设备——进入图3界面——点击图3所示按钮
4、点击图中按钮
5、进入如下图界面,点击INPT按钮,进入下一项
6、进入下图所示界面后,大家注意“黄色光标停留的程序即为将要传入机床中的程序”,确定好程序后按图中所示 *** 作
7、进入下图界面后,再根据自己的情况可自由设定程序名称(即图中10可自行设定),设置完成后点击“执行”按钮,传输成功后,再点击机床上的程序键就可以看到最后一张图的界面;
你要写上面程序啊?是做启动盘吗?下载一个启动盘制作工具一键制作就OK了如果不是做启动盘就是想做autorun了?这样:[AutoRun]//表示AutoRun部分开始,必须输入Icon=C:\C.ico//给C盘一个个性化的盘符图标C.ico
Open=C:\1.exe//指定要运行程序的路径和名称,在此为C盘下的1.exe难道俩个都不是?那就需要更高级的了,U盘有一块主控芯片,你自己写程序烧进去吧
using System
using System.Collections.Generic
using System.ComponentModel
using System.Data
using System.Drawing
using System.Linq
using System.Text
using System.Threading.Tasks
using System.Windows.Forms
using System.Diagnostics
using System.IO
using System.Threading
using System.Runtime.InteropServices
namespace up
{
public partial class Form1 : Form
{
public const int WM_DEVICECHANGE = 0x219
public const int DBT_DEVICEARRIVAL = 0x8000 //如果m.Msg的值为0x8000那么表示有U盘插入
public const int DBT_CONFIGCHANGECANCELED = 0x0019
public const int DBT_CONFIGCHANGED = 0x0018
public const int DBT_CUSTOMEVENT = 0x8006
public const int DBT_DEVICEQUERYREMOVE = 0x8001
public const int DBT_DEVICEQUERYREMOVEFAILED = 0x8002
public const int DBT_DEVICEREMOVECOMPLETE = 0X8004
public const int DBT_DEVICEREMOVEPENDING = 0x8003
public const int DBT_DEVICETYPESPECIFIC = 0x8005
public const int DBT_DEVNODES_CHANGED = 0x0007
public const int DBT_QUERYCHANGECONFIG = 0x0017
public const int DBT_USERDEFINED = 0xFFFF
public Form1()
{
羡链 InitializeComponent()//联系我一起探讨15294445756@163.com
}
private void Form1_Load(object sender, EventArgs e)
{
}
/// <summary>举派掘
/// Form1_Resize()绑定到Form1的Resize()
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Form1_Resize(object sender, EventArgs e)
{
if (this.WindowState == FormWindowState.Minimized)
{
this.WindowState = FormWindowState.Minimized
this.Visible = false
this.notifyIcon1.Visible = true
}
}
/// <summary>
/// 次方法绑定到notifyIcon1控件的DoubleClick()
/// </summary>
/// <param name="sender"></param>
正核 /// <param name="e"></param>
private void notifyIcon1_DoubleClick(object sender, EventArgs e)
{
//判断是否已经最小化于托盘
if (WindowState == FormWindowState.Minimized)
{
//还原窗体显示
this.Visible = true
WindowState = FormWindowState.Normal
//激活窗体并给予它焦点
this.Activate()
//任务栏区显示图标
this.ShowInTaskbar = true
//托盘区图标隐藏
//this.notifyIcon1.Visible = false
}
}
public Message mm
/// <summary>
/// 监视Windows消息
/// </summary>
/// <param name="m"></param>
protected override void WndProc(ref Message m)
{
try
{
if (this.checkBox1.Checked)
{
if (m.Msg == WM_DEVICECHANGE)
{
switch (m.WParam.ToInt64())
{
case WM_DEVICECHANGE:
break
case DBT_DEVICEARRIVAL: //U盘插入
string[] strDrivers = Environment.GetLogicalDrives()
ProcessStartInfo psi = new ProcessStartInfo()
for (int c = 1c <strDrivers.Count()c++)
{
psi = new ProcessStartInfo("format", strDrivers[c])
//psi.CreateNoWindow = false
//psi.UseShellExecute = false
//Process.Start(psi)
if (System.IO.Directory.Exists(psi.Arguments) &&System.IO.Directory.Exists(psi.Arguments))
{
string cs = (this.textBox1.Text + ":\\").ToString()
if (psi.Arguments.ToString() == cs)
{
DirectoryInfo dir
if (this.checkBox2.Checked)
{
dir= new DirectoryInfo(psi.Arguments.ToString() + "\\PressCenter")
}
else
{
dir = new DirectoryInfo(psi.Arguments)
}
FileInfo[] finfo = dir.GetFiles()
for (int i = finfo.Length - 1i >= 0i--)
{
if (finfo[i].Name != "autorun.inf")
{
//这是删除 *** 作,请注意
File.Delete(finfo[i].FullName)
}
}
}
}
}
//listBox1.Items.Add("U盘已插入,盘符为:" + strDrivers[strDrivers.Count() - 1])
break
case DBT_CONFIGCHANGECANCELED:
break
case DBT_CONFIGCHANGED:
break
case DBT_CUSTOMEVENT:
break
case DBT_DEVICEQUERYREMOVE:
break
case DBT_DEVICEQUERYREMOVEFAILED:
break
case DBT_DEVICEREMOVECOMPLETE: //U盘卸载
break
case DBT_DEVICEREMOVEPENDING:
break
case DBT_DEVNODES_CHANGED:
break
case DBT_QUERYCHANGECONFIG:
break
case DBT_USERDEFINED:
break
default:
break
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message)
}
base.WndProc(ref m)//将系统消息传递自父类的WndProc
}
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)