Delphi-PRAXiS
Seite 1 von 4  1 23     Letzte »    

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Msn contact list (https://www.delphipraxis.net/128313-msn-contact-list.html)

Razor 27. Jan 2009 19:12


Msn contact list
 
First of all i wrote this code second of all it dosen't work as it should.Well what i want to do is that it adds only people with certain status to the list.



Delphi-Quellcode:
 

 const
  MISTATUS_UNKNOWN = $00000000;
  MISTATUS_OFFLINE = $00000001;
  MISTATUS_ONLINE = $00000002;
  MISTATUS_INVISIBLE = $00000006;
  MISTATUS_BUSY = $0000000A;
  MISTATUS_BE_RIGHT_BACK = $0000000E;
  MISTATUS_IDLE = $00000012;
  MISTATUS_AWAY = $00000022;
  MISTATUS_ON_THE_PHONE = $00000032;
  MISTATUS_OUT_TO_LUNCH = $00000042;
  MISTATUS_LOCAL_FINDING_SERVER = $00000100;
  MISTATUS_LOCAL_CONNECTING_TO_SERVER = $00000200;
  MISTATUS_LOCAL_SYNCHRONIZING_WITH_SERVER = $00000300;
  MISTATUS_LOCAL_DISCONNECTING_FROM_SERVER = $00000400;

function contactslist(status:MISTATUS):string;

  var
  MSNMessenger: IMessenger;
  MSNMyContacts: IMessengerContacts;
  MSNMyContact: IMessengerContact;
  v_Count: Integer;
  begin

 for v_Count := 0 to MSNMyContacts.Count - 1 do          

 begin
    if MSNMyContact.Status=status then // <<< compiler shows error here!!!

    MSNMyContact := (MSNMyContacts.Item(v_Count) as IMessengerContact);
   result:= MSNMyContact.FriendlyName +  ' ' +MSNMyContact.FriendlyName;


  end;
   end;

  procedure TfrmMain.Button2Click(Sender: TObject);

begin

    ListBox1.Items.Add(contactslist( MISTATUS_ONLINE));
  end;

Meflin 27. Jan 2009 19:15

Re: Msn contact list
 
Could you tell us the error message - maybe we could help you then :roll:

But obviously you are trying to use an unreferenced interface - How do you think this should work exactly?

Razor 27. Jan 2009 19:16

Re: Msn contact list
 
This gets contact list it just doesnt get what i want:( to get list with status.


---------------------------
Debugger Exception Notification
---------------------------
Project MSNMessengerAPIController.exe raised exception class EAccessViolation with message 'Access violation at address 0047F15B in module 'MSNMessengerAPIController.exe'. Read of address 00000000'.
---------------------------
Break Continue Help
---------------------------

mkinzler 27. Jan 2009 19:19

Re: Msn contact list
 
Try to debug it, so you can tell us in wich line the exception is raised

Razor 27. Jan 2009 19:19

Re: Msn contact list
 
Zitat:

Zitat von mkinzler
Try to debug it, so you can tell us in wich line the exception is raised

if MSNMyContact.Status=status then // <<< compiler shows error here!!!

Namenloser 27. Jan 2009 19:22

Re: Msn contact list
 
You access MSNMyContacts without initializing it first. Btw, you should really format your code properly.

mkinzler 27. Jan 2009 19:24

Re: Msn contact list
 
Zitat:

Delphi-Quellcode:
if MSNMyContact.Status=status then // <<< compiler shows error here!!!

    MSNMyContact := (MSNMyContacts.Item(v_Count) as IMessengerContact);
   result:= MSNMyContact.FriendlyName +  ' ' +MSNMyContact.FriendlyName;

You only can evaluate the reference after assigning an object to it. Maybe you have to change the order

Razor 27. Jan 2009 19:25

Re: Msn contact list
 
Initilized but still same error and this gets me thinking :roll:


Even if i change the line order still the same error

Delphi-Quellcode:
 
if MSNMyContact.Status=status then BEGIN
for v_Count := 0 to MSNMyContacts.Count - 1 do
MSNMyContact := (MSNMyContacts.Item(v_Count) as IMessengerContact);
result:= MSNMyContact.FriendlyName +  ' ' +MSNMyContact.FriendlyName;

Delphi-Quellcode:
 function contactslist(status:MISTATUS):string;
  var
  MSNMessenger: IMessenger;
  MSNMyContacts: IMessengerContacts;
  MSNMyContact: IMessengerContact;
  v_Count: Integer;
  begin
  MSNMessenger := MessengerAPI_TLB.CoMessenger.Create;
  MSNMyContacts := (MSNMessenger.MyContacts as IMessengerContacts);


 for v_Count := 0 to MSNMyContacts.Count - 1 do
 begin
 if MSNMyContact.Status=status then BEGIN

 MSNMyContact := (MSNMyContacts.Item(v_Count) as IMessengerContact);
 result:= MSNMyContact.FriendlyName +  ' ' +MSNMyContact.FriendlyName;


end;
end;
end;

mkinzler 27. Jan 2009 19:29

Re: Msn contact list
 
If you wanna pour water out of an bottle, you have to open it first. You still evaluate an reference before you ajust it to an object!!!

Razor 27. Jan 2009 19:31

Re: Msn contact list
 
MISTATUS is ToleEnum


Alle Zeitangaben in WEZ +1. Es ist jetzt 14:01 Uhr.
Seite 1 von 4  1 23     Letzte »    

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