|
What about using the pragma warning??
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Yes ok, it will work...but it's not much of a solution now, is it?
|
|
|
|
|
My program needs to access shares on a different computer but as a different user than the one running the application. If anybody can point me to the basic API functions to do this, it will be greatly appreciated.
The basic function I guess would be to stablish a connection with credentials programatically. In any case I just need a pointer to the documentation.
Thank you
|
|
|
|
|
Something like this:
LogonUserEx() -> ImpersonateLoggedOnUser() -> Access The Shares -> RevertToSelf()
|
|
|
|
|
You can use NetUseAdd() for this.
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Thank you! NetUseAdd() is exactly what I was looking for
The one for the local computer is interesting too, good to know it's also possible.
Thank you both.
|
|
|
|
|
hi
I have problem in sorting the array alphbetically.
I have the names of students only first names.I have the function which works but doesn't gives the consistent result as it should .
So can any one help in getting the problem to be solved
my array declaration is char *names[100];
Best REgards
Jhon
|
|
|
|
|
If you post what you've come up with so far, I'm sure someone here will be able to solve the problem.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
can you use STL? if so, there's functions for that, I think... Or is this a class project in which you have to write your own sorting? If so, look up "Quick sort" or "bubble sort"
My articles
www.stillwaterexpress.com
BlackDice
|
|
|
|
|
what does multi-monitors mean?? Is the same thing shown on both monitors? Do you need 2 or more mouses for each monitor?
|
|
|
|
|
You have one video card driving two monitors (video display hardware), or two video cards driving one or more monitors each. You can sometimes have different desktops on each monitor or one desktop spread across multiple monitors. One mouse typically for the entire system. The mouse typically seamlessly travels from one 'screen' to the next. I like having two monitors because I can run my program on one and run the Visual Studio on the other to debug the program running on the first monitor. Or I can run ZoomIn on the second monitor to spy on the graphics of the first monitor - in this case, it is almost like having the same thing on both monitors, except one of them is magnified. They do not necessarily display the same things, though.
|
|
|
|
|
Hi everybody!!
I have to synchronize a thread with the process. I have to do this :
each 2 seconds and every time OnDraw() is called (event)
For that I have to include "WaitForMultipleObjects" into the thread to wait for this 2 events.
My problem is how can to synchronize the thread...I have had a look to "WaitForMultipleObjects" in MSDN and it says something of using a handler. How can I do it? Could you attach a simple exemple, please?
Thanks you very much.
|
|
|
|
|
Sry, I don't understand your issue.
Don't try it, just do it!
|
|
|
|
|
You need a single 'Event' object. See CreateEvent.
Whne the OnDraw is called or 2 seconds have passed, call SetEvent.
Write your thread to wait on the event handle returned from CreateEvent.
So, then, your thread will 'run' when the event is signalled.
|
|
|
|
|
This is my first experience with maps and I am having some troubles.
I have developed a Logger that can do private logs depending on the client who calls the COM object. Based on the client's information, it needs to find the specific file to log to.
Here is my code:
//(header declarations)
std::map<BSTR, ofstream*> m_FileList;
std::map<BSTR, ofstream*>::iterator mFileListIterator;
//(code)
bool ClientHasCalledBefore;
_bstr_t FileName; //name of the file coming in.
//Look for FileName in map to see if it was called before.
ClientHasCalledBefore = (!(m_FileList.find(FileName) == m_FileList.end()));
// If it has called before, it logs to a clear file.
// If not, it creates the file, then appends the logs.
if (!ClientHasCalledBefore)
{
ofstream *ofstr = new ofstream(FileName, ios::out);
m_FileList[FileName] = ofstr;
*m_FileList[FileName] << "EntryToBeLogged";
m_FileList[FileName]->close();
}
else
{
m_FileList[FileName]->open(FileName, ios::app);
*m_FileList[FileName] << "EntryToBeLogged";
m_FileList[FileName]->close();
}
Okay. This code leads me to my first question. When I enter a new file into the map, sometimes it does not enter properly and the next time the conditional is checked, the FileName is not found. It does this sometimes the first one to three times it runs through. After the first couple of times, everything works fine. Because I am opening the file clean, this overwrites the first couple of entries. Any suggestions so that my conditional finds the entry in the map the first time?
//**************
In my destructor, I have this code to add a footer to every file:
for (m_FileListIterator = m_FileList.begin(); m_FileListIterator != m_FileList.end(); ++m_FileListIterator)
{
(m_FileListIterator->second)->open(FileListIterator->first, ios::app);
*(m_FileListIterator->second) << "FooterToBeAdded";
(m_FileListIterator->second)->close();
}
I think something is totally flawed with this. Sometimes it will append to a file I would have never created in my code, making a new file. Other times it will log the footer into the same file multiple times. It is almost as if it is not iterating.
Again, this is my first experience with any of this. Any help is much appreciated. Thank you.
|
|
|
|
|
Hello ChemmieBro, next time you post here please make sure you check on the "Do not treat <'s as HTML tags" checkbox below the input window: otherwise your < 's and > 's won't show up properly. For the benefit of other readers, I'm reproducing here the definition of m_FileList with the bracket thing right:
std::map<BSTR, ofstream*> m_FileList; The problem you're having is most likely the following: when you look up an item in std::map , the key you pass is compared against those of the elements stored in the map. So far so good, but in your case it is BSTR s that are used as keys, and these are pointers: so, instead of comparing the contents pointed to by the BSTR , it is the pointer addresses that std::map is taking into account, certainly not what you want. The most straightforward solution is to use as keys another type of objects with the right comparison semantics, like for instance MFC CString or some other wrapper around raw BSTR s.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
Thanks for your help. I'm brand new to using BSTRs also.
I do not have access to MFC here, so the CString is out. I will look into using some kind of wrapper around the BSTRs.
|
|
|
|
|
Check Michael Dunn and Nishant Sivakumar's Complete Guide to C++ Strings, Part II [^], you might find what you need there.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
Thank you so much. It was a pretty simple fix using the _bstr_t class instead of the BSTR. My inexperience with BSTR and _bstr_t got the best of me. I don't know why I chose BSTR in my map instead of _bstr_t. But everything is working fine now!
|
|
|
|
|
The following code works gives the b::B no appropriate default constructor err
while it works out fine without the virtual code words.
Can someone explain it/ how to make it pass compilation?
class B
{
public:
B(int a) {printf("BBB%d\n",a);}
};
class D : public virtual B
{
public:
D(int a):B(a) {printf ("DDD%d\n",a);};
};
class DD : public virtual D
{
DD(int a) (a) {printf ("DDD2%d\n",a);};
};
int _tmain(int argc, _TCHAR* argv[])
{
D d(3);
return 0;
}
Keep it simple
|
|
|
|
|
Change the definition of DD as follows:
class DD : public virtual D
{
DD(int a): <font color="#ff0000">B(a),</font> D(a) {printf ("DDD2%d\n",a);};
}; You may ask, why does one need to explicitly construct B , when D already does it? This is a fundamental characteristic of virtual inheritance. To illustrate the issue, consider the following class hierarchy:
struct Top
{
Top(int x){...}
};
struct Middle1: virtual public Top
{
Middle1(int x):Top(x){...}
};
struct Middle2: virtual public Top
{
Middle2(int x):Top(x){...}
};
struct Bottom: public Middle1, public Middle2
{
Bottom():Middle1(1), Middle2(2){}
}; As you know virtual inheritance makes Base objects contain only one instance of Top , like depicted in the diagram:
Top
/\
/ \
/ \
Middle1 Middle2
\ /
\ /
\/
Bottom Now take a look at Bottom 's constructor and ask yourself the following: How is the Top suboject of Bottom initialized? According to Middle1 , it is constructed with x==1 , but Middle2 calls Top 's constructor with x==2 ...
The fundamental problem is that, when virtually inheriting from Top , one cannot assume exclusive rights to the derived-from class, as it is likely to be shared among other unrelated classes. Recognizing this problem, C++ dictates the following: a virtually derived-from class Top must be explicitly constructed from the most derived class constructor, and all other calls to constructors of Top are ignored. Hence your problem.
This issue does not arise to the surface when the Top class has a default constructor, which could be the reason why you haven't met the problem before. Hope this helps.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
Want a Boost forum in Code Project? Vote here[^]!
|
|
|
|
|
even the pixels is not contiguous,how to copy and paste through appications?
|
|
|
|
|
|
if i make a program that should handle a certain file type (for example, i want to make another notepad that should handle files of extension .txt), what do i have to do to associate that file type (in my case .txt) with my own program (in my case, let's say GNotepad.exe) so that by double-clicking a .txt file in the explorer it should open my notepad instead of the classic one ? oh, and i would reaaaaaaly apreciate if you have an example of source code. thanX a lot ...
|
|
|
|
|