delphi
----------------------
uses
  ShareMem,
  SysUtils,Dialogs,
  Classes,cxGrid,cxExportGrid4Link;
type p_cxGrid = ^TcxGrid;
{$R *.res}function ExportGridToExcel(cxGrid:p_cxGrid):boolean;stdcall;
begin
  ShowMessage('init ok');
  ShowMessage('ok');
  ShowMessage(IntToStr(cxGrid.ViewCount));
  ShowMessage(IntToStr(cxGrid.Levels.Count));
  cxGrid.Enabled := false;
  Result := true;
end;exports
ExportGridToExcel;begin
end.cbb

解决方案 »

  1.   

    cb部分的代码    // 从动态连接的Dll中导入函数
        typedef bool (* ExportExcelType)(TcxGrid *);
        ExportExcelType a;    // 加载dll
        HINSTANCE ins;
        ins = LoadLibrary("ExportGrid.dll");
        if (ins == NULL)
            throw "Can't Load Library!";
        // 加载函授
        a = (ExportExcelType )GetProcAddress(ins,"ExportGridToExcel");
        if (a)
        {
                a(cxGrid1);
            ShowMessage("ok");
        }
        // 释放Dll
        if (!FreeLibrary(ins))
        {
            throw "Can't Free!";
        }
      

  2.   

    // 从动态连接的Dll中导入函数
       // typedef bool (* ExportExcelType)(TcxGrid *);
        typedef bool __stdcall (* ExportExcelType)(TcxGrid *);//声明为Stdcall    ExportExcelType a;    // 加载dll
        HINSTANCE ins;
        ins = LoadLibrary("ExportGrid.dll");
        if (ins == NULL)
            throw "Can't Load Library!";
        // 加载函授
        a = (ExportExcelType )GetProcAddress(ins,"ExportGridToExcel");
        if (a)
        {
                a(cxGrid1);
            ShowMessage("ok");
        }
        // 释放Dll
        if (!FreeLibrary(ins))
        {
            throw "Can't Free!";
        }