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,

Recommended Answers

All 16 Replies

thats because you made a console application. You need to make a windows library.

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.

I guess file->new->dll wizard was too obvious

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.

Well thats different, in what way is it not working? what function definition do you have? Do you get errors?

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 := char(byte(S) xor (Key shr 8));
Key := (byte(Result) + 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) and $FC shr 2;
Result := Result + Alphabet[idx+1];
// 2nd char
idx := (ord(st) 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) 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,

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 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.

Perhaps what you expected is different to normal win32 operation - sounds like you're thinking .net

Perhaps what you expected is different to normal win32 operation - sounds like you're thinking .net

i m not think about the .net.

i want to create a dll in delphi which is work in vb6.0 simple.

Try posting in the vb forum then, as ive used DLLs in other languages but not vb 6 and before.

Try posting in the vb forum then, as ive used DLLs in other languages but not vb 6 and before.

ok LizR.

but u have try to call a dll which are built in delphi and use in other language.

should i remove stdcall and use only export function or create a procedure which is call this Encrypt function.

I guess you didnt understand my last post. Yes, just not vb.

ok i'll post it in vb forum.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.