943,682 Members | Top Members by Rank

Ad:
You are currently viewing page 1 of this multi-page discussion thread
Nov 6th, 2008
0

Make dll in Delphi

Expand Post »
Hello Friends,

How can i made an DLL which is used in vb 6.0 as a reference.

i have made an DLL which give the exact result in delphi console application but not add as a reference in vb 6.0

Thanks,
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
poilkjmnb is offline Offline
18 posts
since Nov 2008
Nov 6th, 2008
0

Re: Make dll in Delphi

thats because you made a console application. You need to make a windows library.
Reputation Points: 196
Solved Threads: 190
Posting Virtuoso
LizR is offline Offline
1,735 posts
since Aug 2008
Nov 6th, 2008
0

Re: Make dll in Delphi

Click to Expand / Collapse  Quote originally posted by LizR ...
thats because you made a console application. You need to make a windows library.
Hello LizR,

Thanks for the reply.
but how to make the windows liberary. please give me any example.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
poilkjmnb is offline Offline
18 posts
since Nov 2008
Nov 6th, 2008
0

Re: Make dll in Delphi

I guess file->new->dll wizard was too obvious
Reputation Points: 196
Solved Threads: 190
Posting Virtuoso
LizR is offline Offline
1,735 posts
since Aug 2008
Nov 7th, 2008
0

Re: Make dll in Delphi

Click to Expand / Collapse  Quote originally posted by LizR ...
I guess file->new->dll wizard was too obvious
I m using the same but this DLL is not working in the VB 6.0 application.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
poilkjmnb is offline Offline
18 posts
since Nov 2008
Nov 7th, 2008
0

Re: Make dll in Delphi

Well thats different, in what way is it not working? what function definition do you have? Do you get errors?
Reputation Points: 196
Solved Threads: 190
Posting Virtuoso
LizR is offline Offline
1,735 posts
since Aug 2008
Nov 7th, 2008
0

Re: Make dll in Delphi

Click to Expand / Collapse  Quote originally posted by LizR ...
Well thats different, in what way is it not working? what function definition do you have? Do you get errors?
i m using the function

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,
Reputation Points: 10
Solved Threads: 0
Newbie Poster
poilkjmnb is offline Offline
18 posts
since Nov 2008
Nov 7th, 2008
0

Re: Make dll in Delphi

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.
Reputation Points: 196
Solved Threads: 190
Posting Virtuoso
LizR is offline Offline
1,735 posts
since Aug 2008
Nov 12th, 2008
0

Re: Make dll in Delphi

Click to Expand / Collapse  Quote originally posted by LizR ...
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.
Hello LizR,

so where i need to do changes in the code of dll.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
poilkjmnb is offline Offline
18 posts
since Nov 2008
Nov 12th, 2008
0

Re: Make dll in Delphi

Reputation Points: 196
Solved Threads: 190
Posting Virtuoso
LizR is offline Offline
1,735 posts
since Aug 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in Pascal and Delphi Forum Timeline: Need Help
Next Thread in Pascal and Delphi Forum Timeline: help please





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC