Make dll in Delphi

Please support our Pascal and Delphi advertiser: Programming Forums - DaniWeb Sister Site
Reply

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

Make dll in Delphi

 
0
  #1
Nov 6th, 2008
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,
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Make dll in Delphi

 
0
  #2
Nov 6th, 2008
thats because you made a console application. You need to make a windows library.
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.
Reply With Quote Quick reply to this message  
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

Re: Make dll in Delphi

 
0
  #3
Nov 6th, 2008
Originally Posted by LizR View Post
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Make dll in Delphi

 
0
  #4
Nov 6th, 2008
I guess file->new->dll wizard was too obvious
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.
Reply With Quote Quick reply to this message  
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

Re: Make dll in Delphi

 
0
  #5
Nov 7th, 2008
Originally Posted by LizR View Post
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Make dll in Delphi

 
0
  #6
Nov 7th, 2008
Well thats different, in what way is it not working? what function definition do you have? Do you get errors?
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.
Reply With Quote Quick reply to this message  
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

Re: Make dll in Delphi

 
0
  #7
Nov 7th, 2008
Originally Posted by LizR View Post
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,
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Make dll in Delphi

 
0
  #8
Nov 7th, 2008
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.
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.
Reply With Quote Quick reply to this message  
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

Re: Make dll in Delphi

 
0
  #9
Nov 12th, 2008
Originally Posted by LizR View Post
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.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Make dll in Delphi

 
0
  #10
Nov 12th, 2008
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Pascal and Delphi Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC