问题:
App1.exe调用xxx.Dll,并传递一些参数给xxx.Dll,
使xxx.Dll中的一些变量获得数值!
然后让App1.exe启动App2.exe,而App2.exe要使用xxx.Dll中已经存在数值的变量!难、难、难!!!难死我了!唉~~~~~~
怎么办?

解决方案 »

  1.   

    就是说App2.exe要使用App1.exe的xxx.Dll
      

  2.   

    var
        image1 : timage;例如参数Pic1显示图像1,参数Pic2显示图像2:procedure TForm1.FormActivate(Sender: TObject);
    begin
              if (paramcount{ 参数个数 }<1) or
                 (paramstr(1)='Pic1') then
                 image1.Picture.LoadFromFile('c:\pic1.BMP')
              else
              if (paramstr(1)='Pic2') then
                 image1.Picture.LoadFromFile('c:\pic2.BMP');
    end;paramstr(n) n=1 --- paramcount 为第n个参数, 
      

  3.   

    进程间通讯的问题:
    用映射文件或WM_COPYDATA等等.
      

  4.   

    不难啊,先启动App1.exe改变xxx.dll中的值,然后用app2.exe访问就可以啦,太简单了吧
      

  5.   

    cg1120(代码最优化-§雪是冷的,人是暖的§) :
      你说的是不同的App之间,通过命令行方式传递参数的方法
      和我的问题不一样!我要的是xxx.Dll驻留,多个应用程序公用其中方法,
      而且xxx.Dll中的参数、状态要有App1.exe(主程序)改变,
      其他程序(子程序)只是引用bpint(流离) :
      你说的方法我没用过,能不能说得再详细点?或者哪里有资料可供参考?谢谢 !
      

  6.   

    Linux2001(努力工作中...) :
      你有相关例子吗?如何直接访问呢?
      

  7.   

    通过内存映射文件共享DLL中数据,SETDLLDATA设置;GETDLLDATA得到;可分别在不同的进程中调用,实现进程见共享数据;
    library Project1;{ Important note about DLL memory management: ShareMem must be the
      first unit in your library's USES clause AND your project's (select
      Project-View Source) USES clause if your DLL exports any procedures or
      functions that pass strings as parameters or function results. This
      applies to all strings passed to and from your DLL--even those that
      are nested in records and classes. ShareMem is the interface unit to
      the BORLNDMM.DLL shared memory manager, which must be deployed along
      with your DLL. To avoid using BORLNDMM.DLL, pass string information
      using PChar or ShortString parameters. }uses
      SysUtils,Windows,
      Classes;
      const
       cMMFileName: PChar = 'SharedMapData';{$R *.res}
    var
      MyString : PChar;
      MapHandle  : THandle;
    procedure GetDLLData(test:PChar); StdCall;
    begin
      { Point AGlobalData to the same memory address referred to by GlobalData. }
      strcopy(test,mystring);
    end;
    procedure SetDLLData(test:PChar);StdCall;
    begin
      strcopy(mystring,test);
    end;
    procedure OpenSharedData;
    var
       Size: Integer;
    begin
      { Get the size of the data to be mapped. }
      getmem(mystring,1024);
      Size :=SizeOf(MyString);
      MapHandle := CreateFileMapping(DWord(-1), nil, PAGE_READWRITE, 0, Size, cMMFileName);
      if MapHandle = 0 then
        RaiseLastWin32Error;
      { Now map the data to the calling process's address space and get a
        pointer to the beginning of this address }
      MyString:=MapViewOfFile(MapHandle, FILE_MAP_ALL_ACCESS, 0, 0, Size);
      { Initialize this data }    if MyString = nil then
      begin
        CloseHandle(MapHandle);
        RaiseLastWin32Error;
      end;end;procedure CloseSharedData;
    { This procedure un-maps the memory-mapped file and releases the memory-mapped
      file handle }
    begin
      UnmapViewOfFile(MyString);
      CloseHandle(MapHandle);
    end;procedure DLLEntryPoint(dwReason: DWord);
    begin
      case dwReason of
        DLL_PROCESS_ATTACH: OpenSharedData;
        DLL_PROCESS_DETACH: CloseSharedData;
      end;
    end;exports
      GetDLLData,
      SetDLLData;
    begin
      { First, assign the procedure to the DLLProc variable }
      DllProc := @DLLEntryPoint;
      { Now invoke the procedure to reflect that the DLL is attaching
        to the process }
      DLLEntryPoint(DLL_PROCESS_ATTACH);
    end.
      

  8.   

    不行!呀~~~~~~~
     outer2000(天外流星) 小弟愚笨!烦请mail实例!我的最简单的要求是:
    App1.exe启动xxx.dll传入参数,
    xxx.dll通过这些参数连接数据库
    App2.exe使用xxx.dll中的方法访问数据库!麻烦各位了!~
      

  9.   

    用Ini文件,把appl.exe的参数写入ini文件,然后在app2.exe使用xxx.dll
    时把ini文件中的参数取出连接数据库。
      

  10.   

    我给你的是DLL啊,有两个导出过程,你只要在你的PROJECT里声明调用就可以了;
      

  11.   

    diruser(我来也):
    你的方法缺乏安全性!
      

  12.   

    outer2000(天外流星) :
      QQ联系!谢谢~~