Autor Beitrag
Mike_C
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 207

Win XP
D7 Enterprise
BeitragVerfasst: So 02.03.03 18:50 
Hi!

Ich habe eine Procedure, die als Parameter SHORTSTRINGS und eine TStringList hat. Diese Porcedure befindet sich in einer DLL.

Wenn ich diese Procedure aufrufe, bekomme ich die Fehlermeldung

Cannot assign a TStringList to a TStringList" (so oder so ähnlich)
Woran liegt das?

_________________
Life is, what some people call a mystery. To me life's just a lesson, you're learning when you're through. So why do we try to understand?
AndyB
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 1173
Erhaltene Danke: 14


RAD Studio XE2
BeitragVerfasst: So 02.03.03 19:52 
Also dass die Meldung so lautet kann ich nicht gauben. Ein bischen Code wäre nicht schlecht (Copy&Paste ins Forum), denn dann kann man den Fehler schneller finden.


Zitat:
Diese Porcedure befindet sich in einer DLL.

Da du eine Stringliste übergibst muss ich die Frage stellen, ob du auch die Unit ShareMem in die DLL und in das Hauptprogramm (.dpr) als 1. Unit eingetragen hast.

_________________
Ist Zeit wirklich Geld?
Mike_C Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 207

Win XP
D7 Enterprise
BeitragVerfasst: So 02.03.03 20:02 
Gibt's ne Möglichkeit ShareMem zu umgehen?

_________________
Life is, what some people call a mystery. To me life's just a lesson, you're learning when you're through. So why do we try to understand?
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: So 02.03.03 20:07 
Hallo,
Mike_C hat folgendes geschrieben:
Gibt's ne Möglichkeit ShareMem zu umgehen?

Nur wenn du den Inhalt der Stinglist zu pChar konvertierst und diesen dann übergibst.

Gruß
Klabautermann
Mike_C Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 207

Win XP
D7 Enterprise
BeitragVerfasst: So 02.03.03 20:08 
OK, das wird länger... (Der Source Code)

DLL...
ausblenden volle Höhe Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
var id_SMTP: TIDSMTP;
    id_Message: TIDMESSAGE;

procedure ConfigMail(OutMail, UIN, Password: shortstring; const Filename: shortstring);stdcall;
var F: TExtFile;
begin
  InitCoder;
  Assign(F, Filename);
  Rewrite(F);
  WriteLn(F, Encode(OutMail));
  WriteLn(F, Encode(UIN));
  WriteLn(F, Encode(Password));
  CloseFile(F);
end;

procedure StartMailer(const Filename: shortstring);stdcall;
var F: TextFile;
    s: shortstring;
begin
  id_SMTP := TIDSMTP.Create(Application.MainForm);
  InitCoder;
  AssignFile(F, Filename);
  Reset(F);
  ReadLn(F,S);
  id_SMTP.Host := Decode(s);
  ReadLn(F,S);
  id_SMTP.Username := Decode(s);
  ReadLn(F,S);
  id_SMTP.Password := Decode(s);
  id_SMTP.Port   := 25;
  CloseFile(F);

  id_Message := TIDMESSAGE.Create(Application.Mainform);
end;

procedure ReleaseMailer;stdcall;
begin
  id_SMTP.Free;
  id_Message.Free;
end;

function SendEmail(Sender, Recipient:shortstring;CCList:shortstring;
             sSubject:shortstring;Body:TStringList):boolean;stdcall;
begin
  id_Message.From.text  := Sender;
  id_Message.Sender.text:=id_Message.From.text;

  id_Message.Recipients.EMailAddresses:= Recipient;
  id_Message.CCList.EMailAddresses := CCList;
  id_Message.Subject:=sSubject;

  id_Message.Body.Clear;
  id_Message.Body := Body;

  try
     id_SMTP.Connect;
     id_SMTP.Send(id_Message);
     id_SMTP.Disconnect;
     result:=True;
     except on E : Exception do
       begin
         if id_SMTP.connected then try id_SMTP.disconnect; except end;
         result := false;
       end;
  end;
end;


Im Programm
ausblenden Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
procedure TForm2.btnSendMailClick(Sender: TObject);
var s: TStringlist;
    i, Fehler: integer;
    MMessage: TMAPIMessage;
begin
  s := TStringlist.Create;
  s.Text := Memo1.Text;
  s.Add('I tried the following:');
  if Checkbox1.Checked then s.Add(checkbox1.Caption);
  if Checkbox2.Checked then s.Add(checkbox2.Caption);
  if Checkbox3.Checked then s.Add(checkbox3.Caption);
  if Checkbox4.Checked then s.Add(checkbox4.Caption);
  if Checkbox5.Checked then s.Add(checkbox5.Caption);
  s.Add('but the error still occurs.');
  s.SaveToFile(ExtractFilePath(Application.Exename)+'Body.txt');

  StartMailer(ExtractFilePath(Application.Exename)+'sndmail.cfg');
  SendEMail('gameforge@cheatha.de',Edit1.Text,'','Error Report (CSS-Edit)',s);
  ReleaseMailer;
  s.Free;
end;


Ich hab auch ShareMem als 1.Unit in DLL und Hauptprogramm (.dpr) eingebunden...

_________________
Life is, what some people call a mystery. To me life's just a lesson, you're learning when you're through. So why do we try to understand?
Mike_C Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 207

Win XP
D7 Enterprise
BeitragVerfasst: So 02.03.03 20:11 
@Klabautermann:

Ich glaube, das wird mit in meinem Fall nichts nützen, oder?
Ich muss dann ja wieder den PChar als Stringlist im Message.Body schreiben

edit:

BZW:
Würde es so funzen?
ausblenden Quelltext
1:
2:
SendEmail(Param1, Param2,Param3,Param4,PChar(st.text));
//Param1-4 stehen für Sender, Empfänger, CCList und Subject


und in sendemali selbst
ausblenden Quelltext
1:
2:
3:
...
id_Message.Body.text := Body;
...

_________________
Life is, what some people call a mystery. To me life's just a lesson, you're learning when you're through. So why do we try to understand?


Zuletzt bearbeitet von Mike_C am So 02.03.03 20:17, insgesamt 1-mal bearbeitet
Klabautermann
ontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic starofftopic star
Veteran
Beiträge: 6366
Erhaltene Danke: 60

Windows 7, Ubuntu
Delphi 7 Prof.
BeitragVerfasst: So 02.03.03 20:16 
Hallo,
Mike_C hat folgendes geschrieben:
Ich muss dann ja wieder den PChar als Stringlist im Message.Body schreiben

das ist kein Problem, da ja tStrings.Text die komplette liste als string enthällt. Du kannst diese Eigenschaft sowohl auslesen als auch setzen. Einen String kannst du wierderum einfach in einen pChar konvertieren und andersrum ist es auch kein Problem.
Alternativ kannst du auch tString.CommaText verwenden.

Gruß
Klabautermann
Mike_C Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 207

Win XP
D7 Enterprise
BeitragVerfasst: So 02.03.03 20:18 
thx, ich probier's mal
:D

_________________
Life is, what some people call a mystery. To me life's just a lesson, you're learning when you're through. So why do we try to understand?