You need to pass in the directory to your XULRunner file structure,
and to your Application's directory so that chrome can be loaded
properly.
Example:
// The greBaseDir and appDir varibles are wchar_t pointers, in Windows
these are unsigned shorts and work with the mozilla PRUnichar type.
If you are not using an OS that uses unsigned short to represent
wchar_t, then you should use the appropriate mozilla string conversion
routines to go from your native OS strings to PRUnichar before use.
Note, unix varients all use unsigned int for wchar_t as far as I'm
aware of (FreeBSD, Linux, OS X).
wchar_t *greBaseDir = "C:\Program Files\XULRunner"; // This is where
you will find the xul.dll, chrome subdir and the rest of the
components that are included in the XULRunner distribution
wchar_t *appDir = "C:\Program Files\MyApp"; // This is where you will
find the files specific to your application, such as your chrome
directory, your components dir and so forth. This can be the same as
greBaseDir if you are including the GRE with your application and not
using a system wide XULRunner. It is recommended however that you use
the system wide XULRunner if at all possible so your app gets updates
when XULRunner is updated on the system.
nsCOMPtr<nsILocalFile> xulDir;
result = NS_NewLocalFile(nsString(greBaseDir), PR_TRUE,
getter_AddRefs(xulDir));
if(NS_FAILED(result)) {
Gecko_SetLastError(0x1002);
return(FALSE);
};
nsCOMPtr<nsILocalFile> appDir;
result = NS_NewLocalFile(nsString(appBaseDir), PR_TRUE,
getter_AddRefs(appDir));
if(NS_FAILED(result)) {
Gecko_SetLastError(0x1003);
return(FALSE);
};
result = XRE_InitEmbedding(xulDir, appDir, nsnull, nsnull, 0);
if(NS_FAILED(result)) {
Gecko_SetLastError(0x1004);
return(FALSE);
};
On Apr 29, 12:46 am, dNafigator <[EMAIL PROTECTED]> wrote:
> #define XP_WIN 1
> #define XPCOM_GLUE 1
>
> #include <windows.h>
> #include <string>
>
> #include "xpcom-config.h"
> #include "nsCOMPtr.h"
> #include "nsILocalFile.h"
> #include "nsStringAPI.h"
> #include "xulapp/nsXULAppAPI.h"
> #include "nsXPCOMGlue.h"
> #include "xulapp/nsXULAppAPI.h"
> #include "nsEmbedCID.h"
> #include "nsComponentManagerUtils.h"
>
> XRE_InitEmbeddingType XRE_InitEmbedding;
> XRE_TermEmbeddingType XRE_TermEmbedding;
>
> #pragma comment ( lib, "xpcomglue.lib" )
>
> int APIENTRY WinMain ( HINSTANCE hInstance, HINSTANCE hPrevInstance,
> LPSTR lpCmdLine, int nCmdShow )
> {
> nsDynamicFunctionLoad nsFuncs[] = {
> {"XRE_InitEmbedding", (NSFuncPtr*)&XRE_InitEmbedding},
> {"XRE_TermEmbedding", (NSFuncPtr*)&XRE_TermEmbedding},
> {0, 0}
> };
>
> TCHAR xpcomPath[_MAX_PATH] = TEXT("./xpcom.dll");
> rv = XPCOMGlueStartup ( xpcomPath );
> rv = XPCOMGlueLoadXULFunctions ( nsFuncs );
> rv = XRE_InitEmbedding ( 0, 0, 0, 0, 0 );
> ....
>
> }
>
> (MSVC Express 2005)
> in the above code 'XRE_InitEmbedding' failes with the result
> 0x80070057
> i'm new to the mozilla embedding. what did I miss?
>
> the startup folder of the application is the 'bin' directory of the
> XULrunner SDK.
> 'xul-runner.exe application.ini' <a href="http://developer.mozilla.org/
> en/docs/Getting_started_with_XULRunner">from this tutorial<a> shows a
> 'Hello world' window
> thanks in advance
_______________________________________________
dev-embedding mailing list
[email protected]
https://lists.mozilla.org/listinfo/dev-embedding