Aking,here!
#include <windows.h>
#include "mylabel.h"
#pragma hdrstop
extern __declspec(dllexport)
bool __stdcall MySelDir(LPCTSTR Title,LPCTSTR Msg,LPTSTR Dir);
#pragma argsused
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
{
return 1;
}
//---------------------------------------------------------------------------
bool __stdcall MySelDir(LPCTSTR Title,LPCTSTR Msg,LPTSTR Dir)
{
Form1=new TForm1(NULL);
Form1->Caption =AnsiString(Title);
Form1->Edit1->Text =Form1->DirectoryListBox1->Directory;
Form1->Label1->Caption =AnsiString(Msg);
if(Form1->ShowModal()==mrOk)
{
strcpy(Dir,Form1->Edit1->Text.c_str());
delete Form1;
return true;
}
delete Form1;
return false;
}
调用的.cpp:
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
extern "C" __declspec(dllimport)
bool __stdcall MySelDir(LPCTSTR Title,LPCTSTR Msg,LPTSTR Dir);
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
char Dir[100];
if(MySelDir("dll demo"," select a directory",Dir))
{
MessageBox(Handle,("you have selected "+AnsiString(Dir)).c_str(),"dll demo",MB_OK);
}
}