As I said before, XPCOM works fine while I don't close the browser
(after I restart firefox after the xpcom installation).
IDNA.xpt and IDNA.h was generated by xpidl.exe. There is another
classes I didn't put here because it's "internal". The xpcom main
classes are here:
======================= IDNA.idl
#include "nsISupports.idl"
[scriptable, uuid(096B7F86-2E47-4BF1-9A18-0D46D81EAEAC)]
interface IDNA : nsISupports
{
readonly attribute string Id;
string GetLastError();
};
======================= DNA.h
#ifndef _DNA_H_
#define _DNA_H_
#include "IDNA.h"
#define DNA_CONTRACTID "@company.com.br/DNA/DNA;1"
#define DNA_CLASSNAME "DNA Component"
#define DNA_CID {0x096b7f86, 0x2e47, 0x4bf1, { 0x9a, 0x18, 0x0d, 0x46,
0xd8, 0x1e, 0xae, 0xac }}
class DNA : public IDNA
{
public:
NS_DECL_ISUPPORTS
NS_DECL_IDNA
DNA();
virtual ~DNA();
private:
char m_errormsg[200];
};
#endif
======================= DNA.cpp
#include "comutil.h"
#include "DNA.h"
#include "RegistryId.h"
#include "nsMemory.h"
NS_IMPL_ISUPPORTS1(DNA, IDNA)
DNA::DNA()
{
/* member initializers and constructor code */
}
DNA::~DNA()
{
/* destructor code */
}
NS_IMETHODIMP DNA::GetId(char * *aId)
{
char* ret = NULL;
CRegistryId reg;
ret = reg.GetRegistryId();
if( ret )
{
*aId = ret;
}
else
{
strncpy( m_errormsg, reg.GetLastError(), sizeof( m_errormsg )
);
*aId = "";
}
return NS_OK;
}
NS_IMETHODIMP DNA::GetLastError(char **_retval)
{
*_retval = m_errormsg;
return NS_OK;
}
============================ DNAModule.cpp
#include "nsIGenericFactory.h"
#include "DNA.h"
NS_GENERIC_FACTORY_CONSTRUCTOR(DNA)
static nsModuleComponentInfo components[] =
{
{
DNA_CLASSNAME,
DNA_CID,
DNA_CONTRACTID,
DNAConstructor
}
};
NS_IMPL_NSGETMODULE("DNAModule", components)
_______________________________________________
dev-tech-xpcom mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-tech-xpcom