gecko-dev/cmd/winfe/winpref.c

67 строки
1.9 KiB
C
Исходник Обычный вид История

1998-03-28 05:44:41 +03:00
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include <windows.h>
1998-03-28 05:44:41 +03:00
#include "jsapi.h"
#include "xp_core.h"
#include "xp_mcom.h"
#include "prefapi.h"
extern HINSTANCE hAppInst;
#define GETRESOURCE(A, B, C) ((LPSTR) LockResource((A) = LoadResource((B), FindResource((B), (C), RT_RCDATA))))
#define ZAPRESOURCE(A) (UnlockResource(A), FreeResource(A))
1998-03-28 05:44:41 +03:00
static char
szss[] = "%s%s",
szPref[][9] = {
"init", "all", "mailnews", "editor", "security", "win", "config"
},
szprefs[] = "_prefs"
;
1998-03-28 05:44:41 +03:00
#define _PREFS_ 7
1998-03-28 05:44:41 +03:00
int pref_InitInitialObjects(JSContext *js_context, JSObject *js_object)
{
BOOL fok = 1; jsval result; HGLOBAL hglobal; LPSTR lpstr; char s[MAX_PATH]; register r;
1998-03-28 05:44:41 +03:00
if (js_context && js_object)
for (r = 0; r < _PREFS_; r++) {
wsprintf(s, szss, szPref[r], szprefs);
1998-03-28 05:44:41 +03:00
fok = ((lpstr = GETRESOURCE(hglobal, hAppInst, s))?
JS_EvaluateScript(js_context, js_object, lpstr, lstrlen(lpstr), 0, 0, &result): 0);
1998-03-28 05:44:41 +03:00
#ifndef XP_WIN32
ZAPRESOURCE(hglobal);
1998-03-28 05:44:41 +03:00
#endif
#ifdef DEBUG
if (!fok) {
char szdebug[MAX_PATH * 2];
1998-03-28 05:44:41 +03:00
wsprintf(szdebug, "Initialization failure - %s.", s);
MessageBox(0, szdebug, "pref_InitInitialObjects", MB_ICONINFORMATION);
}
1998-03-28 05:44:41 +03:00
#endif
}
1998-03-28 05:44:41 +03:00
return(fok);
1998-03-28 05:44:41 +03:00
}