|
$a = DllStructCreate("char vdrive[424]")
DllCall("VDRIVESDK.dll", "int", "VdriveMount", $a, "vdrive" , "int" , 0)
以下是C的代码
#ifndef Unit1H #define Unit1H //--------------------------------------------------------------------------- #include <Classes.hpp> #include <Controls.hpp> #include <StdCtrls.hpp> #include <Forms.hpp> //--------------------------------------------------------------------------- class TForm1 : public TForm { __published: // IDE-managed Components TButton *Button1; TButton *Button2; TButton *Button3; TButton *Button4; TButton *Button5; TButton *Button6; TButton *Button7; void __fastcall Button1Click(TObject *Sender); void __fastcall Button2Click(TObject *Sender); void __fastcall Button3Click(TObject *Sender); void __fastcall Button4Click(TObject *Sender); void __fastcall Button5Click(TObject *Sender); void __fastcall Button6Click(TObject *Sender); void __fastcall Button7Click(TObject *Sender); private: // User declarations public: // User declarations __fastcall TForm1(TComponent* Owner); char vdrive[424]; }; //--------------------------------------------------------------------------- extern PACKAGE TForm1 *Form1; //--------------------------------------------------------------------------- #endif
LPVOID lpMsgBuf;
char strPath[MAX_PATH];
int t = 0;
t = VdriveMount(vdrive,0);
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
t,
0, // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
Application->MessageBoxA((const char *)lpMsgBuf,"提示",MB_OK);
LocalFree(lpMsgBuf);
t = 0;
strPath[0] = vdrive[0];
strPath[1] = ':';
strPath[2] = 0;
t = DefineDosDevice(DDD_REMOVE_DEFINITION, strPath, NULL);
if(t != 0) Application->MessageBoxA("DefineDosDevice成功", "提示", MB_OK); |
|