|
Fantastic. That seems to work a treat.
However, on the inside of the dll, the first function is this..
API seed2key (char *param, BYTE *key)
{
BYTE seed[16];
DWORD i, retLen, seedLen;
BYTE *scanPtr;
i = 0;
scanPtr = strtok(param, " \t\n");
while (scanPtr && i < 16) {
seed[i] = atoi(scanPtr);
scanPtr = strtok(NULL, " \t\n");
i++;
}
seedLen = i;
seedToKey (seed, seedLen, key, &retLen);
return (retLen);
}
the while loop iterates once through correctly, but on the second time the string tokenizer returns 0x0000000 into scanPtr.
When you hover over it in VS, the tooltip says. [scanPtr = 0x00000000 <bad ptr="">].
The above section of code seems to suggest that it is actually requiring a string with the delimeters " ", tab and newline.
Rather confusing - although seemingly a different issue, any ideas?
Thanks for the previous posts!
Paul.
|
|
|
|
|
I'd see if the seedToKey function their calling is exported, it seems like a safer function to use. Otherwise, I'd probably change this:
BYTE seed[16] = {0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,0x9,0xa,0xb,0xc,0xd,0xe,0xf,0x00};
to
char seed[] = {0x1,'\n'...,'\n',0xf,0x00};
You can also eliminate the cast that way.
|
|
|
|
|
Hi All...
I have set up an environment in which a ASP page create a object of COM component deployed in COM+ environment. COM Componenet is launched in a dedicated process(DLLHost). In settings of COM+ application, I have set Enable Idle ShutDown Time to 3 minutes.
But DLLHost.exe does not terminates after 3 minutes. It terminates after around 20-25 minutes.
On windows 2000 DLLHost.exe does not terminates.
Can anyone explain me why this is so and what is the difference between windows2000 and windows server 2003 environment.
Suraj Gupta
|
|
|
|
|
In WinXP SP2, there is a service called "DCOM server process launcher" run via svchost.exe. Today I noticed in Process Explorer that there is a "iexplore.exe" process running as a child of this svchost.exe, and tracking back how I started this instance of Internet Explorer, I had clicked on "2 new email messages" in the MSN Messenger (6.2). This is very interesting and I dont know why internet explorer does not show up as a child process of MSN Messenger itself. Anyone any ideas?
I was curious, I then attached windbg to this svchost.exe and put a breakpoint on NtCreateProcessEx, and you know what, the breakpoint is hit even if I start IE from the Windows Explorer shortcuts. Infact, the breakpoint is hit for every process that I start from windows explorer. The difference, however, is that the process is still created as a child of explorer.exe and not as a child of svchost.exe when I start from Windows explorer.
The questions I have are:
1. How exactly does this DCOM server process launcher work? Are there any architecture overview documentation?
2. How do you communicate with it to start a new process? Which COM interface to use?
3. What decides on who is going to launch the new process? svchost or calling process?
I'm not sure if this is good forum to ask this question, if it is not and you know an alternate forum, please let me know.
thanks!
--s
|
|
|
|
|
Further, on WinXP SP1, this is what I notice when I click on "1 new email message" in MSN Messenger:
1. When I have an instance of IE already running, the new IE window is created off this process.
2. If there are no instances of IE running, a new "iexplore.exe" starts under "svchost.exe -k rpcss" service.
Anyone knows what is happening here?
thanks!
|
|
|
|
|
Not sure if this should be here or in the C# forum but here goes. I want to create an out-of-process COM component (like an ActiveX exe in VB6) in C# - does anybody know how to do this? I've created in-process COM component with no problems. Any ideas/links would be most appreciated.
Cheers
|
|
|
|
|
Hello london_ste,
I've been researching into this a few months back. Basically, you would need to create a .NET factory class (contained inside a DLL Assembly) that exposes methods that internally instantiate .NET classes from .NET Exe Assemblies. Let's call this the "factory" assembly.
This factory assembly will be wrapped up in a COM-callable wrapper via tlbimp.exe and Regasm.exe. It is your gateway to the creation of .NET classes housed inside .NET Exe Assemblies.
.NET Activation/Refletion or Remoting are techniques that can be used to create an instance of a .NET class housed inside a .NET EXE assembly.
The special thing about Remoting is that is can be used to instantiate a class from a running EXE application whereas Activation/Refletion loads an Assembly (DLL or Exe) and instantiates a class from the loaded Assembly module.
An example of a creation method can be fashioned as follows :
public object CreateInstance_ByActivation(string strAssemblyName, string strTypeName);
An unmanaged client (written in C++, say) can call this method as follows :
VARIANT varRet;
...
...
...
IFactory -> CreateInstance_ByActivation
(
bstrAssemblyName,
bstrTypeName,
&varRet
);
the object will be returned via the VARIANT "varRet". "varRet" will contain either an IUnknown pointer or an IDispatch pointer.
I'm planning to write an article on this in the future, watch out for it
Best Regards,
Bio.
|
|
|
|
|
Hi Lim,
Thanks for replying. But to be honest I'm not sure I understand. So what you are saying is wrap the exe in a DLL? and access that? But how is that out-of process? Or do you mean the DLL can instantiate and call directly into the exe which will be runnig outof-process ad somehow hold onto the reference to itso we can call more methods on the external exe?
Do you have any good links on Remoting which may help me understand more... Or any sample code you have which will allow me to work out wahts going would be appreciated....
|
|
|
|
|
Hello london_ste,
>> Or do you mean the DLL can instantiate and call directly into the exe which will be runnig outof-process ad somehow hold onto the reference to itso we can call more methods on the external exe?
Yes, this is what I mean. This DLL is what I refer to as the "Factory" DLL. It is also a .NET Assembly (a class library). Hence we will be working with at least 2 .NET Assemblies : the "factory" assembly and the .NET Exe Assembly which supplies the class that we want to expose to an unmanaged client.
This is how it works : an unmanaged client first talks to the "factory" assembly DLL through COM interface methods that are wrapped in a COM-Callable Wrapper. Let's call this interface the "factory" interface. Internally, the "factory" interface method performs the actual instantiation of the .NET class from the .NET Exe.
An example of such a "factory" method is :
public object CreateInstance_ByActivation(string strAssemblyName, string strTypeName);
The "factory" interface method can do the instantiation via Activation/Reflection or Remoting. After instantiating the .NET class instance (in the .NET Exe), the "factory" interface method delivers the .NET object directly to the unmanaged client by its return value (of type "object", which is translated into an "out" VARIANT parameter by COM interop).
An unmanaged client (written in C++, say) can call this method as follows :
VARIANT varRet;
...
...
...
IFactory -> CreateInstance_ByActivation
(
bstrAssemblyName,
bstrTypeName,
&varRet
);
The .NET object (housed in the .NET Exe Assembly) will be returned via the VARIANT "varRet". "varRet" will contain either an IUnknown pointer or an IDispatch pointer depending on how the class in the .NET Exe is attributed. You would retrieve the interface pointer by using the usual variant macros and functions, e.g. :
if ((V_VT(&varRet) != VT_EMPTY) && (V_UNKNOWN(&varRet) != NULL))
{
*ppTargetObjectUnknown = V_UNKNOWN(&varRet);
(*ppTargetObjectUnknown) -> AddRef();
}
Note that after the .NET Exe Class object has been delivered to the client this way, the "factory" is no longer needed. The client interacts with the object directly. This can be in the form of IDispatch::Invoke() or, if the client has the interface signature of the object, in the form of direct interface method calls (but QueryInterface() must be called on the returned IUnknown pointer first).
With several more developers recently asking for essentially the same information, I think I may want to write my article on this as soon as possible.
Concerning Remoting, there are many good introductory articles in CodeProject. I do recommend one written by me last year :
Simple but potentially useful example of .NET Remoting
http://www.codeproject.com/csharp/ProcessActivator.asp[^]
and
A Simple But Useful Example of .NET Remoting Part 2
http://www.codeproject.com/csharp/ProcessActivator2.asp[^]
Contact me again if you need further clarification.
Best Regards,
Bio.
-- modified at 4:13 Friday 9th December, 2005
|
|
|
|
|
I'm a beginner of COM. I just saw some sample codes:
DictionaryObj.cpp
<br />
extern "C" const IID IID_Dictionary = <br />
{ 0x54bf6568, 0x1007, 0x11d1,<br />
{ 0xb0, 0xaa, 0x44, 0x45, 0x53, 0x54, 0x00, 0x00} } ;<br />
I don't understand the purpose of extern "C".
Since IID_Dictionary will not be exported, why to use this prefix?
Thanks.
|
|
|
|
|
The IID has to be visible across all .obj files that are using it.
Say IID_IDictionary is defined in fileOne.cpp (which when compiled generates fileOne.obj)
And in FileTwo.cpp you are referencing IID_IDictionary, the linker will error out unless the IID has the extern "C", as this extern "C" basically tells the linker that the IID is defined in another obj file.
Marco M.
|
|
|
|
|
Hi,
Problem Context: We are writing a COM component which is used in web-service.
Problem Facing : Accessing a COM component from ASP page or any scripting language is what we all know. But we wish to call web-services from a COM component, which does background processing and is suppose to issue HHTP request or somehow able to communicate with web-server.
The COM component will not have any user interface.
Regards,
Amol B. Ravatale
|
|
|
|
|
|
I'm using the OleDbConnection object to retrieve the contents of an
Excel Worksheet as a DataSet. This works fine when testing the
MyExcel.GetMonthly() method call.
When I call MyExcel.GetMonthly() from a Serviced Component, it bombs.
Code snippet:
OleDbConnection cn = new OleDbConnection(CnString);
cn.Open(); <-- Error occurs here
In an effort to isolate the problem I created a new class and called
MyExcel.GetMonthly() from it. Without ServicedComponent inheritence it
works fine. With ServicedComponent inheritence it crashes with:
A condition has occurred that indicates this COM+ application is in an unstable state or is
not functioning correctly. Assertion Failure: !m_punk
Server Application ID: {6E4E5709-D807-46DD-819E-2B3D150FC547}
Server Application Instance ID:
{C73018C7-1BB0-4DB2-A9DB-4D9E22521507}
Server Application Name: MSRBLL
The serious nature of this error has caused the process to terminate.
COM+ Services Internals Information:
File: d:\qxp_slp\com\com1x\src\comsvcs\jit\jit.cpp, Line: 858
Comsvcs.dll file version: ENU 2001.12.4414.258 shp
Any thoughts?
|
|
|
|
|
Guess I'll answer my own post
To ways to solve this problem:
1.) Put the assembly in the GAC
2.) Put the class that works directly with Excel in it's own
Class Library project. It doesn't need to inherit from ServicedComponent,
only the rest of the Data Acess Layer needed COM+.
<signature>
It's good to be alive
|
|
|
|
|
I use a MFC client program and an ATL DCOM server. The ATL Dcom server uses a hidden window to send back events to my clients. In my MFC-program I set up an Event sink using the "TEventHandler" template class.
The event sink is created in MFC-ui thread, I don't create any other new threads.
In the eventsink I allocate/free dynamic memory and store this in static pointer. At some point in MFC-UI thread I also allocate/free and store data at the same pointer.
At frequent times my program crashes and gives ACCESS VIOLATION. (On some machines it never crashes ...)
Is this because the Eventsink and the MFC UI-thread can be seen as different threads. (although I don't create any new.)
If so,would it help if I protected my data to be used in both threads using a lock,... Or do I have to allocate my memory in the eventsink in private heap (is the problem that new/delete are not thread safe) ?
Thanxs,
-- modified at 11:46 Saturday 26th November, 2005
|
|
|
|
|
It depends on how the following questions get answered...
Do you get the events at all?
I assume you do.
Are you runing both the server and the client on the same machine?
If not, try doing because it's sp much easier to debug.
How have you initialized COM in your client? STA, MTA or free-threaded?
I guess the "hidden window" in the server is a UI-thread.
How is COM initialized in that thread?
Try STA if you haven't done so already.
Is the interface marshalled properly since the call is made fram a different apartment?
If you have multiple threads accessing the same data it shall always be protected with some kind of mutual exclusion. I prefer critical sections.
If your client initializes COM as a STA and all interfaces are properly marshalled, your event sink should get called from the one and only thread in your client by the proxy which performs a SendMessage in the background to the apartment thread.
This would be the simple and most straight-forward way to go, but could cause some performance bottle-necks that may require a rewrite to using a multithreaded or free-threaded solution.
Hope this helps
--
Roger
It's supposed to be hard, otherwise anybody could do it!
|
|
|
|
|
Anyone have experience in porting COM components to Linux? I am trying to port the DEFINE_GUID macro definitions and Guids in general to Linux.
Thanks,
Bob
|
|
|
|
|
|
One convenient way to copy a collection of files to the clipboard is the implement the IContextMenu interface (then ivoking commands like "copy", "delete",...). For this you need to call GetUIObjectOf on the files parent folder (IShellFolder interface).
This even works when the files belongs to different folders (subfolders) since you provide files PIDLs that are relative to the parent folder one.
But I've got a situation where the files belong to different drives. And I can't build PIDLs relative to C:\something\ for files belonging to D:\someother\. It would also be the same with network folders.
1/ Can I build PIDLs relative to another drive ?
or
2/ Can I have an IShellFolder interface common to severall drives so that I can call a successfull GetUIObjectOf for the IContextMenu interface
or
3/ Another solution ?
Thanks
Yarp
http://www.senosoft.com/
|
|
|
|
|
I do think this is the right place to post this, because as I understand Office Automation is just a fancier word for COM to Office.
I've done a small program that generates a bunch of worddocumnets and sends it either to printer or as a attached file in an e-mail.
The printing works fine, it prints all the generated docs with the recipients name and stuff.
The problem is with the mail. When my program tells word to send it to the specified e-mails, I first get a warning that a program is trying to use my mail and I can allow it to do so for an amount of time. This is fine, I can live with that.
But then there comes another warning(excuse my bad english translation, I get the error message in swedish):
A program is trying to send automatic e-mail. Will you allow this? If this is unexpected, it could involve a virus and you should choose No.
Then I have to wait for about 5 seconds before I can press Yes.
Is there any way to get around this message, or should I try a diffent approach? I've already allowed the program to use my mail program.
I use MailMerge functions from word to send the documents, both to printer and to mail.
I really hope someone can help me out
/Markus
|
|
|
|
|
Microsoft added this to Outlook after one of the slews of e-mail viruses. In older versions of outlook (98 and maybe 2000), this could be turned off, but I've never been able to find a way around it with outlook 2003. I ended up getting a 3rd party component for sending out e-mails. Sorry I don't have a better answer.
|
|
|
|
|
Hi
Is it possible to pass the object (in C# which has got methods and member variables) to a COM in VC++? If so how to implement it?
Please Help.
Many Thanks
Diana
|
|
|
|
|
Hi Diana
I'm not sure if there is a way of doing what you want, probably yes. Maybe some COM guru over here could point it out. You'd have to manage interfaces like IMarshal, IStreamXXX, and similars to stream your object from one side to the other, but as I said I don't know too much about the subject.
Anyway you could encapsulate your object into a COM interface (which provide access to members and methods), and then, pass the interface pointer to COM.
You can ask in microsoft.public.win32.programmer.ole. I think you will get a better answer there.
Best regards.
|
|
|
|
|
Hi
I think I need to explain more.
There is one class say Class1 and it is implementing an interface IClass1. Object of this class is communicating with a COM in VC++ by calling a method in a class from COM. Before coming out of this method it is required to call method in Class1.
IClass1 pointer is available in COM through type library and object of the class is passed to COM as VARIANT. I have reached till this point and don't know how to proceed. Or is there any other way to implement it?
Thanks in Advance
Diana.
|
|
|
|
|