已通过getprocaddress(getmodulehandle('opengl32.dll'),'glBegin')得到函数指针,但不知如何传递参数已达到修改glBegin的值.

解决方案 »

  1.   

    先要申明一下
    比如
    procedure TForm1.Button1Click(Sender: TObject); 
    type 
      TIntFunc=function(i:integer):integer;stdcall; 
    var 
      Th:Thandle; 
      Tf:TIntFunc; 
      Tp:TFarProc; 
    begin 
      Th:=LoadLibrary(’Cpp.dll’); {装载DLL} 
      if Th>0 then 
       try 
        Tp:=GetProcAddress(Th,PChar(’TestC’)); 
        if Tp<>nil then begin 
         Tf:=TIntFunc(Tp); 
         Edit1.Text:=IntToStr(Tf(1)); {调用TestC函数} 
        end 
        else 
          ShowMessage(’TestC函数没有找到’); 
       finally 
          FreeLibrary(Th); {释放DLL} 
       end 
      else 
       ShowMessage(’Cpp.dll没有找到’); 
    end;