| | |
Make dll in Delphi
Please support our Pascal and Delphi advertiser: Programming Forums - DaniWeb Sister Site
![]() |
•
•
Join Date: Nov 2008
Posts: 18
Reputation:
Solved Threads: 0
•
•
•
•
Well thats different, in what way is it not working? what function definition do you have? Do you get errors?
library Project2;
{ 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,
Classes,
Dialogs;
{$R *.res}
const
C1 = 43941;
C2 = 16302;
var
Result : string;
function BorlandEncrypt(const S: String; Key: Word): String;
var
I: byte;
begin
SetLength(Result,Length(S));
for I := 1 to Length(S) do begin
Result[I] := char(byte(S[I]) xor (Key shr 8));
Key := (byte(Result[I]) + Key) * C1 + C2;
end;
end;
const
Alphabet : string[64] = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
function Encode64(st : string) : string;
var
i,idx : integer;
begin
Result := '';
i := 1;
while i <= length(st) do
begin
// 1st char
idx := ord(st[i]) and $FC shr 2;
Result := Result + Alphabet[idx+1];
// 2nd char
idx := (ord(st[i]) and $3 shl 4);
if i+1 <= length(st) then idx := idx + (ord(st[i+1]) and $F0 shr 4);
Result := Result + Alphabet[idx+1];
// 3rd char
if i+1 <= length(st) then
begin
idx := (ord(st[i+1]) and $F shl 2);
if i+2 <= length(st) then idx := idx + (ord(st[i+2]) and $C0 shr 6);
Result := Result + Alphabet[idx+1];
end
else
Result := Result + '=';
// 4th char
if i+2 <= length(st) then
begin
idx := (ord(st[i+2]) and $3F);
Result := Result + Alphabet[idx+1];
end
else
Result := Result + '=';
// next source char
Inc(i,3);
end;
end;
function Encrypt(password : string) : string; StdCall;
begin
{ ----old encrypt ----
result := '';
for i := 1 to length(password) do
result := result + char( (ord(password[i]) xor 43) + 11 ); }
// new encrypt
password := BorlandEncrypt(password,17732);
Result := '<' + Encode64(password) + '>';
//Result := '<' + Encode64(password) + '>';
end;
Exports
Encrypt;
Begin
end.
but when call this DLL in VB it is not add as reference in project.
If anything wrong in this or need to change to make it compatible.
Thanks,
•
•
Join Date: Aug 2008
Posts: 1,735
Reputation:
Solved Threads: 186
You havent exported any functions so theres nothing for it to use.
You also have used String - against the advice at the top of the file.
You also have used String - against the advice at the top of the file.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
•
•
Join Date: Aug 2008
Posts: 1,735
Reputation:
Solved Threads: 186
You are just plain lazy
http://delphi.about.com/od/windowssh...dll_basics.htm
http://delphi.about.com/od/windowssh...dll_basics.htm
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
![]() |
Similar Threads
- can anyone compile this code ? (Pascal and Delphi)
- DLL problem (C++)
- Debug an Exe from other Exe which loads it in Delphi7 (Pascal and Delphi)
- Please help - Trying to store an .ini in a DLL but still be able to edit it (Pascal and Delphi)
- so...tutorials, tips and tricks, and many more.... (Pascal and Delphi)
- Microsoft .NET FAQ (ASP.NET)
Other Threads in the Pascal and Delphi Forum
- Previous Thread: Need Help
- Next Thread: help please
| Thread Tools | Search this Thread |






