Click here to Skip to main content
15,888,802 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<< This is my python code >>
<< (Step 1) - I am registering the class of this python file for this PythonUtil class by executing this code in the pythonwin.exe >>


class PythonUtil:
    _public_methods_ = ['funct’]
    _reg_progid_ = "PythonUtil.Utilities"
    _reg_clsid_ = "{73B6791B-C161-4F26-9402-D4AE4BC602AB}"

    def funct(self, val, item=None):
	print "hi"

if __name__=='__main__':
  print "COM server being registered..."
  import win32com.server.register
  win32com.server.register.UseCommandLine(PythonUtil)



output:
com being registered.
pythonUtil.utilities registered


<< (step2) - I am having this code in c# >>
C#
private void button_Click(object sender, EventArgs e)
{
object instance =Activator.CreateInstance(Type.GetTypeFromProgID("PythonUtil.Utilities"));
 if (instance != null)
 {
   Type type = instance.GetType();
   for (int y = 0; y < ((checkedListBox1.CheckedItems.Count)); y++)
   {
   object objRet = type.InvokeMember("SwapCaseString", BindingFlags.Default | BindingFlags.InvokeMethod, null, instance, paramList);                   
   }
                
}

}



<< (step 3) - executing this c# code , allows me to call the function 'funct' and
It works fine for me >>

----------- Upto here everything is fine --------------------

But my query is,
1. I dont want to do the execution process of (Step 1) , instead I need that to be registering the classID process through C# itself.
2. Let me make it little bit clear ,
I am allowed to write the code in python , but I cannot execute it in pythonwin.
Instead I have a button click in c#, which will first registers that class or executes that python dynamically and Executes in c#
so for that I need an alternative.

<hope u="" understand="" my="" requirement=""><please help="">
Posted
Updated 19-Dec-11 17:08pm
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900