|
ListView_SetColumn is how things were done in C. I thought ATL offered some wrapper classes for UI ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Can you please explain ?
How its can be done in ATL ?
I realy need help with that.
Thanks.
-- modified at 4:57 Wednesday 28th March, 2007
|
|
|
|
|
I am trying to display data from a list box and an entry field in list box. how do i do that?
|
|
|
|
|
Wow Use a vector
#include <vector>
std::vector<vbidiot> _vbidiots;
_vbidiots.push_back( denilda82);
My code assumes vbidiot has a copy constructor... it must
led mike
|
|
|
|
|
hi everyone,
i created a custom COM component (.exe) which is used by another .dll. i compiled the both components fine, including the code snippet below; but i get a runtime access violation error on line of exe->Dummy() after CoCreateInstance returns S_OK. it gives different addresses for each different method of the .exe component i try.
this code is inside a method of the .dll component
HRESULT hr = 0;<br />
ATLVERIFY(SUCCEEDED(CoInitialize(NULL)));<br />
ATL::CComPtr<ISomething> exe; <br />
hr = exe.CoCreateInstance(CLSID_Something,NULL,CLSCTX_LOCAL_SERVER);
ATLASSERT(SUCCEEDED(hr) && exe != NULL);<br />
ATLVERIFY(SUCCEEDED(exe->Dummy()));
exe.Release();
My .exe component is non-attributed just like the .dll (not sure if it makes any difference), i have built and registered the proxy-stub class fine, and also my .exe file is registered with "exe /RegServer".
i think there is one more thing to be done but just couldn't find out what. if it were the registry script or something, i shouldn't be getting an instance of the .exe component. any ideas ? please have some !!
-- modified at 14:18 Thursday 22nd March, 2007
edit: i converted the .exe interface to be non-dual (it was a dual interface before) and this time exe->Dummy() returns "A null reference pointer was passed to the stub."
|
|
|
|
|
CComPtr is a template and its argument is the interface it should contain, e.g. CComPtr<IDispatch> . It looks like you have omitted the interface UUID. It could be a posting error and that "<" and ">" were interpreted as HTML tags.
Have you tried using the DLL version as an inproc server?
If you haven't, please do so and tell us what happens.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
i created another project whose proxy-stub is merged and now the problem is resolved into another one:
i use HKEY in some of the functions as in and out parameters (they use registry keys), and my IDL file thinks HKEY is void *, contrary to the caller class, which sees HKEY as struct HKEY__* (as it should). i think this causing inconsistency between the client and the server, since i get "bad variable type" (or something similar) from CoCreateInstance only when there is a method with a parameter typed HKEY in the server.
i tried redeclaring HKEY in IDL file,including winnt.h but no luck. any hope here?
|
|
|
|
|
I'm confused about what you're doing. If you're doing what I think you are, in my opinion you've complicated things more than necessary.
In your first post you said that the interface was originally a dual interface. This means that it inherits from IDispatch, but a client would have the ability to call the interface methods through vtable calls. There are two major benefits from using an interface that inherits from IDispatch: (a) a wide variaty of clients can use it such as IE and (b) you can rely on typelib marshalling so you don't have to distribute your own proxy-stub DLL.
Both (a) and (b) requires that your interface is automation compatible, i.e. the oleautomation attribute is added to the interface declaration in the IDL file.
This also implies that you can only use data type that conforms to automation, i.e. data types that can be represented by a VARIANT . A HKEY cannot be represented in a VARIANT , thus you cannot use it; it won't even make it through the MIDL compiler.
Another thing that bothers me is more a design issue.
Originally you're creating a out-of-process server. Why would you open a registry key in one process and simply hand it over to another process? I have no idea what the server should do with the registry key, but I suggest that whatever it is it should be given a path where the modifications should be done and open the registry solely.
Suppose that the exe-server is distributed to another machine, then it wouldn't even be the same registry.
So I guess it's about two questions:
1. What is the server supposed to do with the registry?
2. What are the limitations of the server in the aspect of automation and distribution?
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
i'm trying to create a broker process for an internet explorer toolbar to work on windows vista.
internet explorer (only in vista) puts the toolbar on low registry profile on most of the web pages (all except those in trusted zone), which gets things complicated. you open a trusted site and toolbar tries to read from HKCU, you open another site and it tries to read from HKLM\Software\Microsoft\InternetExplorer\LowRegistry... something.
so what i'm doing is to use an executable file (which will always work on low profile) to do the trick. toolbar just says "save the setting", and turn away. executable will always save these settings to the LowRegistry key.
this is what i understood on msdn articles, did i simply misunderstood them?
|
|
|
|
|
I don't get why the server has to be an out-of-process server.
Do you have any links to the articles that describe this?
"It's supposed to be hard, otherwise anybody could do it!" - selfquote "High speed never compensates for wrong direction!" - unknown
|
|
|
|
|
sure, here it is
http://msdn.microsoft.com/library/en-us/ietechcol/dnwebgen/protectedmode.asp
|
|
|
|
|
ajitatif angajetor wrote: did i simply misunderstood them?
Maybe. The article seems to say that depending on the IL the process "write" operations are restricted. However the lowest IL level has write access to HKEY_CURRENT_USER\Software\LowRegistry key so I would believe all higher IL's would as well. It seems that is what you need write access for (based on your post) and therefore you do NOT need a broker process with elevated IL access... if I understand your posts correctly.
led mike
|
|
|
|
|
nice touch,
but the moment you ask for HKEY_CURRENT_USER in a low integrity process, windows vista will give you the HKEY_CURRENT_USER\Software\LowRegistry key. so the low integrity process will read/write to a position like HKEY_CURRENT_USER\Software\LowRegistry\<user_id>\Software\LowRegistry
|
|
|
|
|
Ok but I don't understand why that is a problem.
led mike
|
|
|
|
|
Hi, folks.
I'm creating an edit control via superclassing in CWindowImpl, which works fine. However, though I can type in the control and get the fetch, I get none of the other control behavior niceties I'm used to getting for free. I've had to manually create the caret, the caret doesn't go to the end after typing each character, highlighting doesn't appear when I try to select text, etc.
I figure either I've done something boneheaded to hose the control (all too believable), or for some reason you have just to manually implement all this with ATL / CWindowImpl. Being an old MFC guy, I'm used to banging out a quick CEdit and it just works, so I'm not sure where things are going south.
Anyone have any thoughts on this?
Thanks,
|
|
|
|
|
Hi,
I'm working on an ATL COM project. The most of the DLL's function is to retrieve and send objects with the software that uses it and do the required job(as in business layer of the 3-layer architecture in object oriented development).
I did have many obstacles while learning this strange library. But now all was gone. I'm good enough to develop what I thought at the beginning. But I have some questions about improving the quality of the written code. When accessing the DLL all code is simple enough to understand and develop. But when accessing an object within another object some strange stuff come in sight.
To explain it simply, I'm gonna give an example which I gave in my another question as well. Take the Course, Department and Student classes again.
Student have attributes as name, surname and these can be accessed with the following methods out of the DLL.
<br />
STDMETHODIMP CStudent::get_name(BSTR* pVal)<br />
{<br />
CComBSTR bstStr(this->name);<br />
*pVal=bstStr.Detach();<br />
return S_OK;<br />
}<br />
<br />
STDMETHODIMP CStudent::put_name(BSTR newVal)<br />
{<br />
_stprintf(this->name, _T("%s"), (LPCTSTR) newVal);<br />
return S_OK;<br />
}<br />
There is nothing strange in this code when accessing Student class from outside of the DLL as below in C#
<br />
Student s = new Student();<br />
s.name = "MyName";<br />
String s = s.name;<br />
But what if I send this class' instance to one of the methods of the Department class as below.
<br />
STDMETHODIMP CDepartment::processSomething(IStudent* std)<br />
{<br />
BSTR stdName;<br />
std->get_name(&stdName);<br />
...<br />
...<br />
return S_OK;<br />
}<br />
or when accessing an class' attribute which is another class.
<br />
...<br />
ICourse* course;<br />
std->get_course(&course);<br />
BSTR courseName;<br />
course->get_name(&courseName);<br />
...<br />
I mean defining variables and/or creating instances of the classes is taking long. I tried another way to make the code easier and shorter. First I define extra methods for each method to access the object's attributes simply as below.
<br />
STDMETHODIMP CStudent::get_name(BSTR* pVal)<br />
{<br />
*pVal = this->getName();<br />
return S_OK;<br />
}<br />
<br />
BSTR CPatient::getName()<br />
{<br />
CComBSTR bstStr(this->name);<br />
return bstStr.Detach();<br />
}<br />
<br />
STDMETHODIMP CStudent::put_name(BSTR newVal)<br />
{<br />
this->putName(newVal);<br />
return S_OK;<br />
}<br />
<br />
void CPatient::putName(BSTR newVal)<br />
{<br />
_stprintf(this->name, _T("%s"), (LPCTSTR) newVal);<br />
return bstStr.Detach();<br />
}<br />
Thus there is two way to access the required method. One for inside of the DLL and one for outside of the DLL. So that when accessing the member of this class within another class is so easy as below
<br />
STDMETHODIMP CDepartment::processSomething(IStudent* std)<br />
{<br />
CStudent* cstd = static_cast<CStudent*>(std);<br />
BSTR stdName = cstd->getName();;<br />
...<br />
BSTR courseName = cstd->getCourse()->getName();
...<br />
return S_OK;<br />
}<br />
Of course one can access the attributes changing them as public instead of private. But we don't want it, do we?
With ICourse the attributes and methods of the class cannot be accessed directly. To access CCourse must be used.
My questions are
*Is casting the ICourse to the CCourse with the static_cast appropriate?
*I searched the web and looked the ATL DLL projects that I found. But I cannot find any example like this. Is the method of accessing the members and writing more methods for them appropriate also?
*Is there any other way to access the attributes of the class?(Without using DLL functions like get_name or get_course)
*Is there any other way to assign IStudent to CStudent to access the attributes of the Student class?
P.S. : I mean sensible not semantically right with appropriate
These post really long. I hope someone patient read it
Thanks to everybody who share ideas about this post.
|
|
|
|
|
We attempt to create new instance of Internet Explorer(6.0/7.0) as a separate process.
We have tried CoCreateInstance,ShellExecute and ShDocVw.
But in all these cases,the new browser is launched as part of an existing IE process.
How do we open the new window as a separate process?
Is there some registry or meta-data settign which enables each IE instance to open as a separate process?
|
|
|
|
|
Hi all
I will going to develop a project like a server application that is one or more client applications will request the data from the database.But database may be in same machine of the server application or other one. I want my application is act as a server application between the client application and database.Now i am using visual studio 2005.So,please help me that which is the best one like ATL or .....?
thanks in advance.....
|
|
|
|
|
Are you asking for technology to prefer in this scenario ? If yes, then opt for web services.
|
|
|
|
|
yah i want to know the technology? can you send any basic tutorial for web services.Right now i know only vc++,i didn't know vc++ .net. So, please explain that should be know the .net technology while creating web service oriented application?
|
|
|
|
|
Start with this[^] article.
|
|
|
|
|
I am working on ATL DLL project. I added some classes and properties and also some classes have attributes whose type are another class. I mean in class Student there is another class' instance named Course.
When I generate DLL and access it within C# as below, I get an exception in 3rd line.
...
student.Course.Name = "CS 100";
student.Course.Name = "CS 100";
student.Course.Name = "CS 100"; //AccessViolationException
student.Course.Name = "CS 100";
...
There is no difference whether to set the same attribute or not. The code returns "System.AccessViolationException was unhandled. Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
But with the below code there is no problem. It works fine
MyDLLLibs.Course c = new MyDLLLibs.Course();
c = student.Course;
c.Name = "CS 100";
c.Name = "CS 100";
c.Name = "CS 100";
c.Name = "CS 100";
Also I want to create a Collection using std::list to send/receive list of objects to/from DLL. For example Department class has a list named Students which is another class contains Student objects. In Students class there is Add, Remove methods and Item and Count attributes. When adding elements to the Students object as shown in below code, it returns FatalExecutionEngineError at 3rd access to Students "again".
MyDLLLibs.Department d = new MyDLLLibs.Department();
MyDLLLibs.Student s1 = new MyDLLLibs.Student();
s1.Name = "Xelon";
s1.Surname = "XYZT";
...
d.Students.Add(s1);
d.Students.Add(s2);
d.Students.Add(s3); //FatalExecutionEngineError
d.Students.Add(s4);
I can't find what is the problem. Is this an initialization or memory allocation problem?
Thanks for your help
|
|
|
|
|
I have more of a design type of question.
Can anyone tell me if it is possible to :
I have a win 32 dll and a C# web service. Instead of creating a c# client, i would like to use my win 32 dll as the client. I use this dll for other things that are all file related. Is it possible for me to make the dll the client and to be able to call the c# web service and send and receive data from it? If so, does anyone have any examples of how to turn an already existing win 32 dll into a client accessing a c# web service?
|
|
|
|
|
I just replied to this in the Visual C++ forum. Please don't cross post.
led mike
|
|
|
|
|
I AM HAVING A PICULIAR PROBLEM REGARDING THE SOFTWARE COMPATABLITY WITH REFRENCE TO WIN2000 & WINXP . THE ARITHMATIC FUNCTIONS OF SUM,MEAN,MAX,MIN,STANDARD DEVIATION ARE WORKING FINE IN WIN2000 BUT ARE SHOWING SOME DATAS WRONG & SOME NULL IN XP .PLEASE SUGGEST ME SOME STEPS TO SOLVE THE ABOVE PROBLEMS.
THANKS & REGARDS,
SATYABATA NAIK
SATYABRAT NAIK
|
|
|
|