Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

can't use a function from dll built in delphi
hi..

i got a dll wrapped in com which was written in delphi,

although i can use in dotnet , trying to access a specific function in
vb6 gets me:

Function marked as restricted or uses a type not supported in Visual
Basic


Report this thread to moderator Post Follow-up to this message
Old Post
Elhanan
01-29-06 11:55 PM


Re: can't use a function from dll built in delphi
> i got a dll wrapped in com which was written in delphi,
>
> although i can use in dotnet , trying to access a specific function in
> vb6 gets me:
>
> Function marked as restricted or uses a type not supported in Visual
> Basic

What's the function signature in your Delphi code?
Also, make sure that you export your function as standard call since
otherwise VB won't be able to call it.
Hope this helps,

Mike


- Microsoft Visual Basic MVP -
E-Mail: EDais@mvps.org
WWW: Http://EDais.mvps.org/



Report this thread to moderator Post Follow-up to this message
Old Post
Mike D Sutton
01-29-06 11:55 PM


Re: can't use a function from dll built in delphi
here you go:

i should note that only the functions:

GetPlaintiffs
GetErrorMessage
GetDocumentTypes

don't work



//
 ****************************************
********************************
//
// Type Lib: E:\dcMgdSrk\DcSrkMgd.tlb (1)
// IID\LCID: {F31081A1-40F2-4DAA-93DC-01DE56B7FEEC}\0
// Helpfile:
// DepndLst:
//   (1) v2.0 stdole, (C:\WINNT\system32\STDOLE2.TLB)
//   (2) v4.0 StdVCL, (C:\WINNT\system32\STDVCL40.DLL)
//
 ****************************************
********************************
//
{$TYPEDADDRESS OFF} // Unit must be compiled without type-checked
pointers.
interface

uses Windows, ActiveX, Classes, Graphics, OleServer, OleCtrls, StdVCL;

//
 ****************************************
*****************************//
// GUIDS declared in the TypeLibrary. Following prefixes are used:

//   Type Libraries     : LIBID_xxxx

//   CoClasses          : CLASS_xxxx

//   DISPInterfaces     : DIID_xxxx

//   Non-DISP interfaces: IID_xxxx

//
 ****************************************
*****************************//
const
// TypeLibrary Major and minor versions
DcSrkMgdMajorVersion = 1;
DcSrkMgdMinorVersion = 0;

LIBID_DcSrkMgd: TGUID = '{F31081A1-40F2-4DAA-93DC-01DE56B7FEEC}';

IID_ITSrkMigdal: TGUID = '{73995D07-F76F-4C5E-B958-55654C85DDE8}';
CLASS_TSrkMigdal: TGUID = '{EE099BDA-6446-4460-8F22-70A94E9E09CF}';
type

//
 ****************************************
*****************************//
// Forward declaration of types defined in TypeLibrary

//
 ****************************************
*****************************//
ITSrkMigdal = interface;

//
 ****************************************
*****************************//
// Declaration of CoClasses defined in Type Library

// (NOTE: Here we map each CoClass to its Default Interface)

//
 ****************************************
*****************************//
TSrkMigdal = ITSrkMigdal;


//
 ****************************************
*****************************//
// Interface: ITSrkMigdal
// Flags:     (256) OleAutomation
// GUID:      {73995D07-F76F-4C5E-B958-55654C85DDE8}
//
 ****************************************
*****************************//
ITSrkMigdal = interface(IUnknown)
['{73995D07-F76F-4C5E-B958-55654C85DDE8}']
function  Init_Db(IniFileName: PChar): Integer; stdcall;
function  Close_Db: Integer; stdcall;
function  GetDocumentTypes: PChar; stdcall;
function  ClaimExists(CompNum: Integer; TviaaNo: PChar): Integer;
stdcall;
function  GetPlaintiffs(CompNum: Integer; TviaaNo: PChar): PChar;
stdcall;
function  GetErrorMessage(ErrorCode: Integer): PChar; stdcall;
end;

//
 ****************************************
*****************************//
// The Class CoTSrkMigdal provides a Create and CreateRemote method to

// create instances of the default interface ITSrkMigdal exposed by

// the CoClass TSrkMigdal. The functions are intended to be used by

// clients wishing to automate the CoClass objects exposed by the

// server of this typelibrary.

//
 ****************************************
*****************************//
CoTSrkMigdal = class
class function Create: ITSrkMigdal;
class function CreateRemote(const MachineName: string):
ITSrkMigdal;
end;

implementation

uses ComObj;

class function CoTSrkMigdal.Create: ITSrkMigdal;
begin
Result := CreateComObject(CLASS_TSrkMigdal) as ITSrkMigdal;
end;

class function CoTSrkMigdal.CreateRemote(const MachineName: string):
ITSrkMigdal;
begin
Result := CreateRemoteComObject(MachineName, CLASS_TSrkMigdal) as
ITSrkMigdal;
end;

end.


Report this thread to moderator Post Follow-up to this message
Old Post
Elhanan
01-30-06 12:55 PM


Re: can't use a function from dll built in delphi
> here you go:
>
> i should note that only the functions:
>
> GetPlaintiffs
> GetErrorMessage
> GetDocumentTypes
>
> don't work
<code snipped>

I would suggest then that it's because those functions return a PChar, try p
utting ShareMem as the _first_ entry in both
your library and project uses clauses and see if that clears things up (alth
ough check for leaks with this technique..)
Alternatively you may want to pass the string back as an OleVariant containi
ng a string which should handle the cleanup
for you.
Failing that, have a look at this old post which demonstrates a different wa
y of passing strings about used by the Win32
API:
http://groups.google.co.uk/group/mi... />
d3c0e08e7f
Hope this helps,

Mike


- Microsoft Visual Basic MVP -
E-Mail: EDais@mvps.org
WWW: Http://EDais.mvps.org/



Report this thread to moderator Post Follow-up to this message
Old Post
Mike D Sutton
01-30-06 12:55 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Visual Basic archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:13 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.