View Single Post
Join Date: Nov 2008
Posts: 18
Reputation: poilkjmnb is an unknown quantity at this point 
Solved Threads: 0
poilkjmnb poilkjmnb is offline Offline
Newbie Poster

Other Language DLL

 
0
  #1
Nov 13th, 2008
Hello Friends,

i m using the function to built DLL in delphi but when call it in vb 6.0 application i m not able to use this dll as reference.

Please help me. Following code which i have used to built delphi DLL.
------------------------------------------------------------------------------
visualbasic Syntax (Toggle Plain Text)
  1. library Project2;
  2.  
  3.  
  4. uses
  5. SysUtils,
  6. Classes,
  7. Dialogs;
  8.  
  9. {$R *.res}
  10.  
  11. const
  12. C1 = 43941;
  13. C2 = 16302;
  14.  
  15. var
  16. Result : string;
  17.  
  18. function BorlandEncrypt(const S: String; Key: Word): String;
  19. var
  20. I: byte;
  21. begin
  22. SetLength(Result,Length(S));
  23. for I := 1 to Length(S) do begin
  24. Result[i] := char(byte(S[i]) xor (Key shr 8));
  25. Key := (byte(Result[i]) + Key) * C1 + C2;
  26. end;
  27. end;
  28.  
  29. const
  30. Alphabet : string[64] = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
  31.  
  32. function Encode64(st : string) : string;
  33.  
  34. var
  35. i,idx : integer;
  36. begin
  37. Result := '';
  38. i := 1;
  39. while i <= length(st) do
  40. begin
  41. // 1st char
  42. idx := ord(st[i]) and $FC shr 2;
  43. Result := Result + Alphabet[idx+1];
  44. // 2nd char
  45. idx := (ord(st[i]) and $3 shl 4);
  46. if i+1 <= length(st) then idx := idx + (ord(st[i+1]) and $F0 shr 4);
  47. Result := Result + Alphabet[idx+1];
  48. // 3rd char
  49. if i+1 <= length(st) then
  50. begin
  51. idx := (ord(st[i+1]) and $F shl 2);
  52. if i+2 <= length(st) then idx := idx + (ord(st[i+2]) and $C0 shr 6);
  53. Result := Result + Alphabet[idx+1];
  54. end
  55. else
  56. Result := Result + '=';
  57. // 4th char
  58. if i+2 <= length(st) then
  59. begin
  60. idx := (ord(st[i+2]) and $3F);
  61. Result := Result + Alphabet[idx+1];
  62. end
  63. else
  64. Result := Result + '=';
  65. // next source char
  66. Inc(i,3);
  67. end;
  68. end;
  69.  
  70. function Encrypt(password : string) : string; StdCall;
  71.  
  72. begin
  73. { ----old encrypt ----
  74. result := '';
  75. for i := 1 to length(password) do
  76. result := result + char( (ord(password[i]) xor 43) + 11 ); }
  77.  
  78. // new encrypt
  79. password := BorlandEncrypt(password,17732);
  80. Result := '<' + Encode64(password) + '>';
  81. //Result := '<' + Encode64(password) + '>';
  82. end;
  83.  
  84. Exports
  85. Encrypt;
  86.  
  87. Begin
  88. end.
Last edited by cscgal; Nov 13th, 2008 at 4:28 pm. Reason: Added code tags
Reply With Quote