[python-win32] Package Py ActiveX object as self-register DLL ??

Niki Spahiev niki@vintech.bg
Tue, 11 Jun 2002 11:34:54 +0300


This is a multi-part message in MIME format.
--------------080201020304040609080506
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Mantila Juhani wrote:
> Hello,
> I'm interested, too, but I'd ask you to be a bit more specific, pls.
> Where's McMillan ?
> Here's an other: I've got a buch of interfaces to implement ( an olb file ).
> Best way to implement those ?  I just learned that some of the classes
> in concern don't implement IDispatch and makepy won't produce all the stuff.
> 
> Juhani

http://www.mcmillan-inc.com/install5_ann.html there is mailing list 
where i posted the patch.

For non IDispatch interfacer i have no experience.

HTH
Niki Spahiev

--------------080201020304040609080506
Content-Type: text/plain;
 name="comdll.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="comdll.patch"

diff -r -u app/installer/MakeCOMServer.py code/installer/MakeCOMServer.py
--- app/installer/MakeCOMServer.py	Thu Jan 24 17:10:30 2002
+++ code/installer/MakeCOMServer.py	Sun Mar 24 16:55:54 2002
@@ -6,7 +6,7 @@
         %(mod)s.%(klass)s._reg_options_ = {'InprocServer32':
              os.path.abspath(
                  os.path.join(
-                     os.path.dirname(sys.executable), "%(dllname)s"))}
+                     os.path.dirname(sys.argv[0]), "%(dllname)s"))}
 """ #mod, klass, dllname
 tmplt = """\
 import sys
diff -r -u app/installer/source/windows/dllmain.c code/installer/source/windows/dllmain.c
--- app/installer/source/windows/dllmain.c	Thu Feb 14 16:56:20 2002
+++ code/installer/source/windows/dllmain.c	Sun Mar 24 16:32:38 2002
@@ -18,7 +18,8 @@
 void releasePythonCom(void);
 HINSTANCE gInstance;
 
-int launch(char const * archivePath, char  const * archiveName)
+int launch(char const * archivePath, char  const * archiveName,
+		   char const * regUnreg) // NIKI
 {
 	static PyInterpreterState *interp = NULL;
 	PyThreadState *thisthread;
@@ -41,9 +42,13 @@
         return -1;
 
 	if (loadedNew) {
+		int argc = 1;
+		char const * argv[2] = { pathnm };
+		if (regUnreg)
+			argv[argc++] = regUnreg;
 		/* Start Python with silly command line */
 		PyEval_InitThreads();
-		if (startPython(1, (char**)&pathnm))
+		if (startPython(argc, argv))
 			return -1;
 		VS("Started new Python");
 		thisthread = PyThreadState_Swap(NULL);
@@ -101,7 +106,7 @@
 
     return 0;
 }
-void startUp()
+void startUp(char const * regUnreg)
 {
 	char thisfile[_MAX_PATH + 1];
 	char *p;
@@ -119,7 +124,7 @@
 	len = p - here;
 	//VS(here);
 	//VS(&thisfile[len]);
-	launch(here, &thisfile[len]);
+	launch(here, &thisfile[len], regUnreg);
 	LoadPythonCom();
 	// Now Python is up and running (any scripts have run)
 }
@@ -199,7 +204,7 @@
 	sprintf(msg, "DllCanUnloadNow from thread %x", GetCurrentThreadId()); 
 	VS(msg);
 	if (gPythoncom == 0)
-		startUp();
+		startUp(NULL);
 	rc = Pyc_DllCanUnloadNow();
 	sprintf(msg, "DllCanUnloadNow returns %x", rc); 
 	VS(msg);
@@ -216,7 +221,7 @@
 	sprintf(msg, "DllGetClassObject from thread %x", GetCurrentThreadId()); 
 	VS(msg);
 	if (gPythoncom == 0)
-		startUp();
+		startUp(NULL);
 	rc = Pyc_DllGetClassObject(rclsid, riid, ppv);
 	sprintf(msg, "DllGetClassObject set %x and returned %x", *ppv, rc);
 	VS(msg);
@@ -229,13 +234,33 @@
 	sprintf(msg, "DllRegisterServerEx from thread %x", GetCurrentThreadId()); 
 	VS(msg);
 	if (gPythoncom == 0)
-		startUp();
+		startUp(NULL);
 	return Pyc_DllRegisterServerEx(fileName);
 }
 
 __declspec(dllexport) int DllUnregisterServerEx(LPCSTR fileName)
 {
 	if (gPythoncom == 0)
-		startUp();
+		startUp(NULL);
 	return Pyc_DllUnregisterServerEx(fileName);
+}
+
+__declspec(dllexport) HRESULT DllRegisterServer() // NIKI
+{
+	char msg[40];
+	sprintf(msg, "DllRegisterServer from thread %x", GetCurrentThreadId()); 
+	VS(msg);
+	if (gPythoncom == 0)
+		startUp("--register");
+	return S_OK;
+}
+
+__declspec(dllexport) HRESULT DllUnregisterServer() // NIKI
+{
+	char msg[40];
+	sprintf(msg, "DllRegisterServer from thread %x", GetCurrentThreadId()); 
+	VS(msg);
+	if (gPythoncom == 0)
+		startUp("--unregister");
+	return S_OK;
 }

--------------080201020304040609080506--