Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi dll Problem (https://www.delphipraxis.net/30863-dll-problem.html)

novelly 30. Sep 2004 12:29


dll Problem
 
hi dp´ler,

habe jetzt mal meine ersten erfahrungen mit dll´s machen dürfen :-(

den folgenden code (nein! nicht mein eigener) wollte ich aus einer .exe in eine .dll kopieren.
in einer .exe funktioniert er einwandfrei . in der .dll bekomme ich beim aufruf immer die meldung:
"EOleSysError: ungültige Syntax"

die prozedur adduser habe ich exportiert !

hat da jemand vielleicht eine idee ? (ist meine erste .dll :freak: )

THX

Code:
unit main;

interface

  function GetObject(name:string): IDispatch;
  procedure adduser; stdcall;

implementation

uses
  ActiveX,
  ActiveDs_TLB,
  ComObj;


function GetObject(name:string): IDispatch;
var
  Moniker: IMoniker;
  Eaten: integer;
  BindContext: IBindCtx;
  Dispatch: IDispatch;
begin
  OleCheck(CreateBindCtx(0, BindContext));
  OleCheck(MkParseDisplayName(BindContext,PWideChar(widestring(name)),Eaten,Moniker));
  OleCheck(Moniker.BindToObject(BindContext, NIL, IDispatch,Dispatch));
  Result := Dispatch;
end;

procedure adduser; stdcall;
var
  Usr  : IADsUser;
  Comp : IADsContainer;
begin
    Comp := GetObject('WinNT://fs1,computer') as IADsContainer;
    Usr  := Comp.Create('user', 'Novelly') as IADsUser;
    Usr.SetInfo;
end;


end.

novelly 1. Okt 2004 18:54

Re: dll Problem
 
OKAY, nach langem suchen und probieren habe ich es gelöst....
in der .exe welche die .dll nutzt wird ein CoInitializeEx(nil, COINIT_MULTITHREADED) fällig !

Mein Proggi funktioniert nun. Ivh wüßte nur zu gerne was ich dort eigentlich getan habe bzw. warum es nicht direkt aus der .dll möglich ist diese Funktion aufzurufen....?!?

Es gab schon mal einen Thread mit ähnlichem Inhalt....
DP-Link


thx


Alle Zeitangaben in WEZ +1. Es ist jetzt 21:44 Uhr.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz