C 識別U盤和碟符

2021-06-03 19:02:44 字數 2573 閱讀 6821

using system;

using system.collections.generic;

using system.componentmodel;

using system.data;

using system.drawing;

using system.text;

using system.io;

using system.windows.forms;

using system.runtime.interopservices;

namespace usb

public const int wm_devicechange = 0x219;

public const int dbt_devicearrival = 0x8000;

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 const int dbt_devtyp_volume = 0x00000002;

// private lockscreen ls = new lockscreen();

public string id = "";

public string value;

public string item;

[structlayout(layoutkind.sequential)]

public struct dev_broadcast_volume

protected override void wndproc(ref message m)

int devtype = marshal.readint32(m.lparam, 4);

if (devtype == dbt_devtyp_volume)

}this.label1.text = this.text;

}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盤解除安裝

driveinfo i = driveinfo.getdrives();

foreach (driveinfo drinfo in i)

this.label1.text += this.text;

// messagebox.show("u盤已經解除安裝", "資訊提示", messageboxbuttons.ok, messageboxicon.information);

}break;

case dbt_deviceremovepending:

break;

case dbt_devicetypespecific:

break;

case dbt_devnodes_changed:

break;

case dbt_querychangeconfig:

break;

case dbt_userdefined:

break;

default:

break;}}

}catch (exception ex)

base.wndproc(ref m);

}private void usb_load(object sender, eventargs e)

public string io(string ff)

return value;

}private void timer1_tick(object sender, eventargs e)

}}

u盤固定碟符 高手固定U盤碟符有絕招

方案一 1 在u盤的某個位置放置乙個ini檔案,暫取名為 changeusb.ini 放在u盤的根目錄,ini檔案只需要兩行 紅色為注釋 subj curdrv 刪除原有的u盤的碟符 show r 1,u 給u盤新分配碟符為u 2 在winpe的核心配置檔案中加一行load命令,這行load命令建議...

u盤固定碟符 如何固定PE下的U盤碟符

方法一 1 在u盤目錄中建立乙個ini檔案,取名為 usb.ini 雙擊開啟,在裡面輸入 subj curdrv show r 1,u 2 在winpe的核心配置檔案中加一行load命令,建議這行load命令放在修正usb驅動之後,通過load命令的前導符 將自動載入u盤中的 usb.ini 檔案。...

檢測是否存在u盤碟符

主要的功能函式如下 uses uselectdriveremovable procedure tform20.formcreate sender tobject begin btn tosd.enabled chkdriveremovable end u盤的 插入和刪除windows會給所有的程式發...