Using windows objects?

Just starting out? Need help? Post your questions and find answers here.
aXend
Enthusiast
Enthusiast
Posts: 103
Joined: Tue Oct 07, 2003 1:21 pm
Location: Netherlands

Post by aXend »

Tnkx for the link. Now I understand a bit more.

Unfortunately these posts made also clear that:
There's no way to view the Interface definitions for now.
So my question still remains: how to use my ActiveX dll's?
See previous post.
Justin
Addict
Addict
Posts: 958
Joined: Sat Apr 26, 2003 2:49 pm

Post by Justin »

To learn how to use an object you have to look at the object docs(properties,methods) not at PB files, for windows objects are at msdn.

Q: How to create an object from a progid?, a new instance of the program, not inside a PB window. like internet explorer, word..

i tried "InternetExplorer.Application" , got the CLSID using the previous code, then cocreateinstance() with IID_IWebbrowser2 and does not work.
Fred
Administrator
Administrator
Posts: 18352
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

You can see all the interfaces definition on the cvs repository: cvs.purebasic.com (residents/interfaces). An interface viewer will be added to the editor soon.
aXend
Enthusiast
Enthusiast
Posts: 103
Joined: Tue Oct 07, 2003 1:21 pm
Location: Netherlands

Post by aXend »

I want to use the Chilkat Mail ActiveX. I did use it with Javascript by defining obj = new ActiveXObject(ProgId). Now I'm trying this with PureBasic.

I coded the following:

Code: Select all

; Test createobject with ChilkatMailMan

Interface IMailMan
  UnlockComponent()
  get_Version()
  Release()
EndInterface

CoInitialize_(0) 

If CoCreateInstance_(?CLSID_ChilkatMailMan,0,1,?IID_IChilkatMailMan,@pobj.IMailMan)=0 
  MessageRequester("PureBasic - ChilkatMailMan", "Enjoy the full object oriented experience")
  pobj\UnlockComponent(UNLOCK_CODE)
  pobj\Release()
Else
  MessageRequester("Warning:","Couldn't init ChilkatMailMan",0)
EndIf 

;CoUninitialize()

End 

DataSection 
  CLSID_ChilkatMailMan: 
    Data.l $A46E5261
    Data.w $C356,$4767
    Data.b $88,$CA,$DF,$CE,$D0,$50,$D0,$9E

  IID_IChilkatMailMan:
    Data.l $CCB7FB40
    Data.w $F4EC,$4678
    Data.b $92,$02,$52,$79,$8D,$A7,$8A,$BA
    
  UNLOCK_CODE:
    Data.s "22540B8F792140"
EndDataSection 
I used examples from C++ headers, but I think I did something wrong, because the program crashes when I use the pobj\UnlockComponent().

This is what I found in the header files:

Code: Select all

-------------------
In CMailMan.h
-------------------
class CMailMan : public ChilkatComponent
{
public:
    CMailMan(void) { }
    virtual ~CMailMan(void) { }

    static CMailMan *Create(void);
    // Pass any interface, such as IUnknown, IChilkatMailMan2, or older interface versions.
    static CMailMan *Create(void *iface);
[....]
    virtual bool UnlockComponent(const char *code) = 0;
    virtual char *get_Version() = 0;
[....]
};

-------------------
In main.cpp:
-------------------
#include <windows.h>
#include "../../../Include/CMailMan.h"
#include "../../../Include/CEmail.h"
#include "../../../Include/CEmailBundle.h"
#include "../loginInfo.h"

int APIENTRY WinMain(HINSTANCE hInstance,
                     HINSTANCE hPrevInstance,
                     LPSTR     lpCmdLine,
                     int       nCmdShow)
{

    ::CoInitialize(0);

    CMailMan *mailman = CMailMan::Create();
    mailman->UnlockComponent(UNLOCK_CODE);
[.....]
    delete mailman;

    ::CoUninitialize();

    return 0;
}

-------------------
In logInfo.h:
-------------------
#define UNLOCK_CODE "22540B8F792140"

I tried to do something with the header converter and the dll importer, but that didn't give any result. What can I do to get it working?
Fred
Administrator
Administrator
Posts: 18352
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

If it's a regular com, you will have to 'Extends IUnknown' for your interface.
aXend
Enthusiast
Enthusiast
Posts: 103
Joined: Tue Oct 07, 2003 1:21 pm
Location: Netherlands

Post by aXend »

I did "some" extension :!: But still I can't do with it what I want. Here's the code.

Code: Select all

; Test createobject with ChilkatMailMan

Interface IChilkatMailMan
  QueryInterface()
  AddRef()
  Release()
;  GetTypeInfoCount()
;  GetTypeInfo()
;  GetIDsOfNames()
;  Invoke()
  get_SmtpHost()
  put_SmtpHost()
  SendEmail()
  SendBundle()
  get_MailHost()
  put_MailHost()
  get_PopUsername()
  put_PopUsername()
  get_PopPassword()
  put_PopPassword()
  get_SmtpPort()
  put_SmtpPort()
  get_MailPort()
  put_MailPort()
  get_MaxCount()
  put_MaxCount()
  get_SizeLimit()
  put_SizeLimit()
  CopyMail()
  TransferMail()
  get_DefaultLanguage()
  put_DefaultLanguage()
  CheckMail()
  get_DefaultCharset()
  put_DefaultCharset()
  get_PreferIsoCharset()
  put_PreferIsoCharset()
  get_PreferMicrosoftCharset()
  put_PreferMicrosoftCharset()
  get_PreferMacCharset()
  put_PreferMacCharset()
  StartMailWatch()
  StopMailWatch()
  UnlockComponent(a.l)
  get_Version()
  QuickSend()
  LoadMbx()
  LoadOutlookFolder()
  get_Filter()
  put_Filter()
  LoadXmlFile()
  LoadXmlString()
  SendViaOutlook()
  get_SmtpUsername()
  put_SmtpUsername()
  get_SmtpPassword()
  put_SmtpPassword()
  ImportCertificates()
  get_LogMailSentFilename()
  put_LogMailSentFilename()
  get_LogMailReceivedFilename()
  put_LogMailReceivedFilename()
  GetAllHeaders()
  DeleteEmail()
  GetHeaders()
  GetFullEmail()
  DeleteBundle()
  DeleteMultiple()
  FetchEmail()
  FetchMultiple()
  VerifyPopConnection()
  VerifyPopLogin()
  VerifySmtpConnection()
  VerifySmtpLogin()
  get_SmtpLoginDomain()
  put_SmtpLoginDomain()
  get_OutlookContactsFolder()
  put_OutlookContactsFolder()
  get_AutoAddContacts()
  put_AutoAddContacts()
  get_SmtpAuthMethod()
  put_SmtpAuthMethod()
  get_SendIndividual()
  put_SendIndividual()
  Unused1()
  LoadMime()
  get_AutoSaveCerts()
  put_AutoSaveCerts()
  GetUidls()
  SaveXmlLog()
  LoadEml()
  DeleteByUidl()
  GetBadEmailAddresses()
  ClearBadEmailAddresses()
  FetchMultipleHeaders()
  get_ReadTimeout()
  put_ReadTimeout()
  SendQ()
  get_ResetDateOnLoad()
  put_ResetDateOnLoad()
  SendCGI()
EndInterface

CoInitialize_(0) 

If CoCreateInstance_(?CLSID_ChilkatMailMan,0,1,?IID_IChilkatMailMan,@pobj.IChilkatMailMan)=0 
  MessageRequester("PureBasic - ChilkatMailMan", "Enjoy the full object oriented experience")
  pobj\UnlockComponent(?UNLOCK_CODE)
  pobj\Release()
Else
  MessageRequester("Warning:","Couldn't init ChilkatMailMan",0)
EndIf 

;CoUninitialize()

End 

DataSection 
  CLSID_ChilkatMailMan: 
    Data.l $A46E5261
    Data.w $C356,$4767
    Data.b $88,$CA,$DF,$CE,$D0,$50,$D0,$9E

  IID_IChilkatMailMan:
    Data.l $CCB7FB40
    Data.w $F4EC,$4678
    Data.b $92,$02,$52,$79,$8D,$A7,$8A,$BA
    
  UNLOCK_CODE:
    Data.s "22540B8F792140"
EndDataSection 
As it is coded here it works without crashes, but as soon as I try to call one of the other functions there's no result. I have header files, but I can't use them with the header converter or with the interface importer, the *.pb files are all empty. :(
I have also IDL files, but no MIDL and I can't find it anywhere to download. Does anyone have a solution or suggestion to get it working?
Justin
Addict
Addict
Posts: 958
Joined: Sat Apr 26, 2003 2:49 pm

Post by Justin »

Sorry, i can't help you. But i suggest a separate phorum for the COM stuff, could be helpful.
Post Reply