Hallo Gemeinde,
ich möchte (habe) eine Prozedure geschrieben, die einen Eintrag in einem Outlook-Ordner sucht und danach das Kontaktfenster üffnet:
<pre>
procedure StartContact(FiledAs : OleVariant); //stdcall;
var
Outlook : Application_;
objContact : Variant;
objContacts : MAPIFolder;
objNameSpace : NameSpace;
FindVariable : String;
begin
FindVariable:= '[FileAs] = ' + Format('%s', [FiledAs]);
Outlook := CoApplication_.Create;
objNameSpace := Outlook.GetNamespace('MAPI');
objContacts:= objNameSpace.Folders.Item('öffentliche Ordner').Folders.Item('Alle öffentlichen Ordner').Folders.Item('Spediteure');
objContact:= objContacts.Items.Find(FindVariable);
objContact.Display;
end;
</pre>
der dll handle sieht wie folgt aus:
<pre>
procedure StartContact(FiledAs : OLEVariant);
var KontaktProzedur: TKontaktProzedur;
Handle: THandle;
begin
Handle:=LoadLibrary('Contact.dll');
if Handle <> 0 then begin
@KontaktProzedur := GetProcAddress(Handle, 'StartContact');
if @KontaktProzedur <> nil then begin
KontaktProzedur(FiledAs);
end;
FreeLibrary(Handle);
end;
end;
</pre>
Leider erhalte ich stets eine Zugriffsverletzung wenn folgende Prozedure die dll aufruft:
<pre>
procedure TfmMain.NameListChange(Sender: TObject);
var
FiledAs : Variant;
begin
FiledAs:= QuotedStr(NameList.Text);
StartContact(FiledAs);
end;
</pre>
Der Benutzer kann im Hauptformular aus einer Drop Down Liste einen Eintrag auswählen, dann startet die dll und das Programm bleibt stehen. Füge ich die "dll-Prozedure" jedoch ins Hauptprogramm ein, läuft das Progi sauber durch. Was mache ich falsch?
<br>
So sieht i.Ü die dll aus - vielleicht liegt ja hier der Fehler.
<pre>
library Contact;
uses
Windows, Messages, SysUtils, ComObj, Outlook_TLB;
procedure StartContact(FiledAs : OleVariant); stdcall;
var
Outlook : Application_;
objContact : Variant;
objContacts : MAPIFolder;
objNameSpace : NameSpace;
FindVariable : String;
begin
FindVariable:= '[FileAs] = ' + Format('%s', [FiledAs]);
Outlook := CoApplication_.Create;
objNameSpace := Outlook.GetNamespace('MAPI');
objContacts:= objNameSpace.Folders.Item('öffentliche Ordner').Folders.Item('Alle öffentlichen Ordner').Folders.Item('Spediteure');
objContact:= objContacts.Items.Find(FindVariable);
objContact.Display;
end;
exports
StartContact;
begin
end.
</pre>
Viele Grüsse<br>
Uwe
ich möchte (habe) eine Prozedure geschrieben, die einen Eintrag in einem Outlook-Ordner sucht und danach das Kontaktfenster üffnet:
<pre>
procedure StartContact(FiledAs : OleVariant); //stdcall;
var
Outlook : Application_;
objContact : Variant;
objContacts : MAPIFolder;
objNameSpace : NameSpace;
FindVariable : String;
begin
FindVariable:= '[FileAs] = ' + Format('%s', [FiledAs]);
Outlook := CoApplication_.Create;
objNameSpace := Outlook.GetNamespace('MAPI');
objContacts:= objNameSpace.Folders.Item('öffentliche Ordner').Folders.Item('Alle öffentlichen Ordner').Folders.Item('Spediteure');
objContact:= objContacts.Items.Find(FindVariable);
objContact.Display;
end;
</pre>
der dll handle sieht wie folgt aus:
<pre>
procedure StartContact(FiledAs : OLEVariant);
var KontaktProzedur: TKontaktProzedur;
Handle: THandle;
begin
Handle:=LoadLibrary('Contact.dll');
if Handle <> 0 then begin
@KontaktProzedur := GetProcAddress(Handle, 'StartContact');
if @KontaktProzedur <> nil then begin
KontaktProzedur(FiledAs);
end;
FreeLibrary(Handle);
end;
end;
</pre>
Leider erhalte ich stets eine Zugriffsverletzung wenn folgende Prozedure die dll aufruft:
<pre>
procedure TfmMain.NameListChange(Sender: TObject);
var
FiledAs : Variant;
begin
FiledAs:= QuotedStr(NameList.Text);
StartContact(FiledAs);
end;
</pre>
Der Benutzer kann im Hauptformular aus einer Drop Down Liste einen Eintrag auswählen, dann startet die dll und das Programm bleibt stehen. Füge ich die "dll-Prozedure" jedoch ins Hauptprogramm ein, läuft das Progi sauber durch. Was mache ich falsch?
<br>
So sieht i.Ü die dll aus - vielleicht liegt ja hier der Fehler.
<pre>
library Contact;
uses
Windows, Messages, SysUtils, ComObj, Outlook_TLB;
procedure StartContact(FiledAs : OleVariant); stdcall;
var
Outlook : Application_;
objContact : Variant;
objContacts : MAPIFolder;
objNameSpace : NameSpace;
FindVariable : String;
begin
FindVariable:= '[FileAs] = ' + Format('%s', [FiledAs]);
Outlook := CoApplication_.Create;
objNameSpace := Outlook.GetNamespace('MAPI');
objContacts:= objNameSpace.Folders.Item('öffentliche Ordner').Folders.Item('Alle öffentlichen Ordner').Folders.Item('Spediteure');
objContact:= objContacts.Items.Find(FindVariable);
objContact.Display;
end;
exports
StartContact;
begin
end.
</pre>
Viele Grüsse<br>
Uwe
Comment