Ver Mensaje Individual
  #1  
Antiguo 07-12-2007
Avatar de Enan0
Enan0 Enan0 is offline
Miembro
 
Registrado: may 2004
Ubicación: Argentina
Posts: 565
Reputación: 20
Enan0 Va por buen camino
Crear una COM DLL

Hola, Buenos dias.

HE creado una DLL Simple DLL, La cual ejecuta una consulta SQL, y luego Desencripta un password. la cual he probado con una aplicacion delphi. y fuiona correctamente. eh aqui en codigo

Código Delphi [-]
uses
  SysUtils,
  Classes,
  Db,
  ADODB,
  windows,
  Xutil,
  Ttpwcryp,
  Scryp,ttid;

{$R *.RES}

   Function DecryptPSw(s:string;Idlow:integer):string;
   var i:integer;
      aux:ShortString;

   begin
      aux:=s;
      RemoveGarbageHex(aux);
      aux:=HexStrToBinStr(aux);
       Decrypt(aux[1],Length(aux));
           for i:=1 to Length(aux) do
              aux[i]:=Char(Ord(aux[i])-IdLow mod i);
           result:=aux;
   end;

   Function Loggin(Usr,Psw:String):boolean; STDCALL;
   var
      Cnx:TADOConnection;
      Query:TADOQuery;
      tmppw:TPasswordString;
      aux:ShortString;
   begin
      if FileExists(ExtractFilePath(ParamStr(0))+'\Connection.udl') then begin
         Cnx:=TADOConnection.Create(nil);
         Cnx.ConnectionString:='FILE NAME='+ExtractFilePath(ParamStr(0))+'\Connection.udl';
         cnx.LoginPrompt:=false;
         Cnx.Open;
         Query:=TADOQuery.Create(nil);
         Query.Connection:=Cnx;
         Query.SQL.Clear;
         Query.SQL.text:='Select SY_ID2,PS_PASSW from t620pers where ps_short=:Short and ps_Type =3';
         Query.ParamCheck :=true;
         Query.Parameters.ParamByName('Short').Value:=Usr;
         Query.Open;
         TmpPw:=UpperCase(Psw);
         if not Query.IsEmpty then begin
            aux:=Query.FieldByName('PS_PASSW').asstring;
            GeneratePw(TmpPw,Query.FieldByName('SY_ID2').AsInteger);
            RemoveGarbageHex(aux);
            aux:=HexStrToBinStr(aux);
             Result:=TmpPw=aux;
         end else result:=false;
         Query.Close;
         Query.free;
         cnx.Close;
         cnx.free;
      end;

   end;

Exports loggin;

end.



E aqui como la ejecuto desde la aplicacion en delphi


Código Delphi [-]

//EdShort.Text,EdPsw.Text son dos Edits en los cuales paso Usuario y password


  Function Loggin(Usr,Psw:String):boolean; stdcall external 'TTLoggin.dll';
implementation

{$R *.DFM}

procedure TForm1.btTestClick(Sender: TObject);
begin
   if loggin(EdShort.Text,EdPsw.Text) then
      ShowMessage('True')
   else
      ShowMessage('False');

end;

end.


El problema que tengo es que dicha DLL quieren ejecutarla desde .net y al parecer no pueden utilizarla.
yo he intentado REgistrarla pero no es posible ya que Luego de ejecutar Regsvr32 me da el sigueitne Error

Cita:

---------------------------
RegSvr32
---------------------------
F:\Download\Pc_San\Programas\Loggin DLL\TTLoggin.dll was loaded, but the DllRegisterServer entry point was not found.

DllRegisterServer may not be exported, or a corrupt version of F:\Download\Pc_San\Programas\Loggin DLL\TTLoggin.dll may be in memory. Consider using PView to detect and remove it.
---------------------------
Aceptar
---------------------------
Alguna iDea de como puedo Crearla Como un objeto COM o como puedo instanciar dicha DLL desde .net?

GRacias
Responder Con Cita