|
AFAIK, the only way to figure out the CLSID of an object is to use an interface which has a GetCLSID()-like method. An interface such as those based on IPersist.
> I need to check its CLSID to figure out what I can do with it.
Why? A COM object can do only what its interfaces expose. Why not just query it for interfaces you can handle...?
--
Ich bin Joachim von Hassel, und ich bin Pilot der Bundeswehr.
Welle: Erdball - F104-G Starfighter
|
|
|
|
|
Hello everyone,
I'm currently working on a COM Server that i want to be a Service and i'm pretty close to get it to work but ...
When i start the COM Server manually all seems to work fine, i can create multiple objects and they will all use my currently running process.
When i start the COM Server as a service, the scripting app does not want to use the Service for a source, instead it starts another instance of my application.
I do call CoInitializeSecurity and set permissions so that anyone can access the library.
Not sure what is preventing my Service to be accessed.
Anyone has a clue ?
DarkByte
|
|
|
|
|
Ok, i found part of my answer in MSDN .. yaya !!
The Library article located in Component Development -> Component Object Model (General) -> Technical Articles -> Creating and Registering COM Components with LocalService gave me a big help to get further in my development process but i still fail and one part of the article seems to be my answer, except i'm not too sure how to handle it. Here is the part i'm talking about:
Coding a COM component in a service is much like coding a traditional service. In the primary thread, start the service dispatcher thread. Next, expose a COM component through the service and not through the primary thread of the service application. Place the COM-specific code in the service. Finally, create proxies to expose the component's interfaces to any clients.
The bold text is what seems to be my answer, but i'm confused as to how to make it.
i figured out how to get dlldata.c, <file>_h.h, <file>_i.h, <file>_p.?.
So, do i just need to create a dll out of these files ?
What kind of registration is required for the Proxy to use my service ?
What about UUID's ? Do the proxy component need new UUID's ?
I guess being redirected to a good article that talk about proxy/server could help me be less confused.
BTW, i'm not using ATL/MFC or whatever .. i edit my IDL file manually. Well, i use MFC but not the COM part of it.
Thanx in advance for any hints
DarkByte
[edit]: Issue was solved by just defining the LocalService key as described in the documentation. My last problem was thinking i was recompiling the Debug version when i actually was recompiling the Release version
|
|
|
|
|
How can I rename an NT user using the ADSI(Active Directory Service Interfaces)? The IADs::SetInfo method can only change user's fullname not rename a user.
|
|
|
|
|
HI~
I would like to ask
How do I change the data in C++ dll by a C# program?
I have ever tried this.
I wrote a dll with VC++. There is a variable in the dll (e.g "m_string"). "m_string" is a LPCTSTR type and it's inital value set by constructor is _T("Hello World"). I also wrote a function for setting the variable. The function is declared like this:
extern "C" _declspec(dllexport) void set(LPCTSTR s)
{
m_string = s;
}
Afterward, I wrote a C# dll assembly. The C# dll import the dll written by C++. The import the dll like this:
#region DLLImports
[DllImport("Test.dll")] //test is the C++ dll filename
private static extern void Set(string s);
#endregion
Finally, I wrote a form to call the method "Set". After the method have finished executing, the value "m_string" does not change. The "m_string" is still "Hello World".
My question is, how to change a variable in dll permanently by a C# library or exe?
Thanks
|
|
|
|
|
What is m_string type ?
are you sure your function is being called?
Create a file output function and call it from your C++ function and have it dump anything or the parameter and your m_string to a file. Then, after you called the function, see if the output file exists.
DarkByte
|
|
|
|
|
HI~
"m_string" is just a variable name.
I am sure that the function is being called as I set the function return -1 in the dll file. When it is back to C#, -1 is shown as I display the return value.
So...
Is there any mistake in other places?
Thanks!
|
|
|
|
|
oops .. i had'nt read correctly the first time,
try making m_string a CString instead of LPCTSTR ?
Everything seems to be fine, but unless you changed your return type to something other than void, you can't assume that its being called properly.
Create a file dump function, something simple like:
<br />
void mydump(LPCTSTR dumptext)<br />
{<br />
CFile f;<br />
<br />
f.Open("c:\\dump.txt", CFile::modeCreate | CFile::modeNoTruncate);<br />
f.Write(dumptext);<br />
f.Write("\n");<br />
f.Close();<br />
}<br />
and your function should be:
<br />
void Out(LPCTSTR t)<br />
{<br />
CString dump;<br />
<br />
m_string = t;<br />
dump.Format("%s - %s", m_string, t);<br />
mydump(dump);<br />
}<br />
Hope this helps you find the problem.
|
|
|
|
|
HI~
I am sure the function work properly.
My situation is that
The dll is loaded will windows startup. The dll is used to so a string on the screen when the windows startup. The string is a variable of the dll. When the dll is loaded, a WM_PAINT message is sent and the OnPaint function is called. The OnPaint function draw the window and text on the screen. I would like to use C# program to make changes to the string so that the screen can show different string dynamically.
I use the code above and try to achieve this result. However, the variable within the extern function is changed but after the function is complete, the string on the screen still not been changed.
So, how to achieve the correct result?
Thanks~
|
|
|
|
|
What if you issue a WM_PAINT after assignment ?
|
|
|
|
|
Hi,
I am developing multithreading COM EXE server. In one of the methods I have called CoCreateInstance, which is made threadsafe by using CSingleLock(&(oneMutext)). The first 2 or 3 instances of CoCreateInstance always succeded. But after some time, call to CoCreateInstance raises an exception. Also heap get corrupted at this point.
Can anybody help me in resolving this issue.
Thanks & Regards,
Mandar
|
|
|
|
|
Are you calling CoInitialize() when entering a thread, and CoUnitialize() when leaving the thread ?
DarkByte
|
|
|
|
|
Hi,
I have a hard questions regarding Shell Namespace Extensions.
I am researching the possiblity of having the following:
1. A shell namespace extension that when installed appears as a new "drive" in the Explorer folder tree, and it shows a tree of "folders" containing "files" the user can browse like a normal drive.
2. Users can open/save files to these "virtual folders" like a normal drive in say MSWord just using the File Open/etc dialogs [so my extension must appear in these dialogs as if it were a normal drive].
3. Programmers can open/create/write/etc using normal API. This will need to be done using .Net, so using System.IO.File , etc. Also need to manipulate directories this way.
I am happy to have to do: FileStream* fs = System.IO.File::Create("mydrivetype:\\x\y\z\abc.txt"); kind of thing.
The extension will not be storing files on the regular file system [or it may, but this is not a requirement], for example, it could be storing to a remote server [maybe like those FTP drives], or through a remote WebService, through HTTP, or to a local database [I need to be really flexible here, I have several possible uses for this technology, so the underlying storage mechansm will be dependant on my implemetation, but it will always expose files and directories.]
(1) is okay.
My problem is doing number (2) and (3).
I have looked at IStorage, IPersistFile, and Asyncronous Pluggable Protocols, but I am not really sure how one would go about doing these things.
What I am hoping to get is some comments on
(a) is this possible?
(b) tips/hints/advice on how best to do (2)/(3), links, even books!!
Many many thanks in advance!!!
Mark
|
|
|
|
|
I'm not the authority in this domain but if i recall from other threads i've seen, you're going to need the DDK to develop this kind of application. What you need looks like a system driver.
And althought i can't be sure, i believe there is a price attached to it too, because even if normal DDK is free, DDK that change file system are worth like 899$ US.
But see what others can come up with, maybe i'm missing a detail somewhere.
DarkByte
|
|
|
|
|
Given the limitations of comercial solutions, I'm writing a custom app installation utility. I'm writing it in a generic manner. However, the application I'm initially writing it for has a mixture of .NET and ASP 3.0/COM+ functionality. As such, from managed code, I need to be able to:
- Create/Delete COM+ Applications and set properties.
- Register/Unregister COM+ components (unmanaged code, NOT assemblies) in those applications and set properties.
I've written a class that successfully creates applications and adds components. However, when using COMAdminCatalog.InstallComponent() to register and add components to the application it adds exactly 18 entries to the registry. By contrast, simply registering a component and its type library from the commandline using regsvr32 adds only 10.
My Issue: Using either COMAdminCatalog.Remove() or resvr32 /u doesn't remove ALL registry entries, but leaves 6 entries, all under HKLM\SOFTWARE\Microsoft\COM3\SelfReg. The entries left in there include a CLSID, ProgID and type library.
My Question: I've searched the .NET fx high and low and looked for options for interop, all to no avail. How do I programmatically remove ALL references of a COM+ DLL from the registry so as not to cause any potential conflicts (DLL hell) in future upgrades where binary compatibility is broken? Thanx!
Boyd Campbell
Systems Engineer
|
|
|
|
|
How about deleting the Tree of keys yourself ?
I'm my COM Component, i delete keys under INTERFACE,APPID,CLSID using a tree delete function .. i delete all keys and subkeys from my classid and under in these 3 keys
|
|
|
|
|
Well, I was hoping there was a programmatic way (via an API perhaps) that does it for me. It seems an oversight to me that using the COMAdminCatalog functionality will register in those locations and yet there's no converse to those actions exposed on that server. Rather dissappointing.
|
|
|
|
|
I understand your disappointment, but sometimes stuff is done a certain for a reason which isnt always obvious at first. Or it could be a bug.
so, until someone brings you a reason or a fix, i suggest you try with a simple registry tree flushing function ! (be careful not to delete all keys).
|
|
|
|
|
Thanx bud...do you have a C# snippet? Doesn't have to be C# though...I'll take whatever you may have. Thanx again.
|
|
|
|
|
Sorry, i dont have time to make a C# sample but check within namespace Microsoft.Win32, you will find classes for Registry and RegistryKey, check info on these and you probably can code something quick.
|
|
|
|
|
Yea...I've actually done a lot with the items that MS.Win32 exposes. I was just looking for the quick way out.
Thanks for your help sir.
|
|
|
|
|
Hi i have actually posted this question in ATL section
I have recieve a few tlb from a vendor . in these tlb there is only interfaces with no coclass at all.
Can any body teach me how to use this interface or point me to a sample
thanks
PS: sorry for double posting, need it urgently
|
|
|
|
|
I've been looking at methods of implementing realtime file monitoring. I have looked at validtec's API hooking SDK, which is not ideal for my purposes.
Alfa's File monitor COM component is superb...
My question is:
Does anybody know of any other alternatives?
Just another copy and paste artist
|
|
|
|
|
You can use this window api FindFirstChangeNotification
it is easy to use, fast and low cpu consumption
|
|
|
|
|
Thank you,
That is fantastic and perfect!
Just another typist
|
|
|
|