|
Hi all. Suppose i were to have a long input from a socket.
<quote>
connected to server: something.host.com : etcetera
Instead of trying to compare the entire string of characters, how would i break it up so that i can only compare a certain string, for example the 'something.host.com' string? This is a std::string too.
|
|
|
|
|
I don't know about any specific APIs to do this, but you can always use the find/rfind/substr
methods to parse a std::string.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I wrote a string parser and posted the article here, and a STL version of the class is included.
http://www.codeproject.com/string/cstringparser.asp[^]
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hello everyone,
I have built MSDN OLE DB Sample Provider and successfully built/debug it using Microsoft Excel as client. I have found that in DllGetClassObject (classfac.cpp), the class SampProv is initialized as the 1st coclass, then DataSource object will be created in QueryInterface.
http://msdn2.microsoft.com/en-us/library/ms715011.aspx
The entry point of a COM server (like this Sample OLE DB Provider) is creating a coclass through DllGetClassObject. My question is, how did Microsoft Excel find the entry point coclass of the OLE DB Provider is SampProv coclass?
I have this question because Excel is a client with no knowledge about any specific application defined CLSID, like SampProv, how could it be aware of this ID (i.e. Excel knows nothing about 3rd party application's specific name of entry point coclass)? In Windows registry, I can not find any related information indicating that SampProv should be the entry point coclass either.
thanks in advance,
George
|
|
|
|
|
Hi, i am having much frustration with this one...
I have a dialog based app in which I want to register its window.
I have tried putting the AfxRegisterClass( ) code inside the InitDialog( ) function, but this has not been successful - at best it just doesn't do the registration, at worst (when I've parred down WINDOWCLASS items (.style, .icon, .cursor) i have got a run time warning about a resource is unavailable.
I am using Studio 6.0 and the utility Spy++ to see if my dialog's window is indeed given a class name - it's not.
I need to register my dialog app so that I can send it messages from another app via PostMessage(window-name, class-name)
Any help?
Thanks!
|
|
|
|
|
You are trying to register an already registered window... which is wrong. Also, the point that after registering a window you would be able to PostMessages to it, is also wrong. PostMessage does nothing with registeration. A window need to be registered in order to be used. If it is already in use, then you can do a PostMessage or SendMessage to it if, of course, you have the HWND of that window.
--
=====
Arman
|
|
|
|
|
Dialog's use a pre-defined window class that we don't have access to.
You can register a class but there's no way to create a dialog window of that class.
You could add a custom, private window property to the dialog's window that other apps can look
for.
You can also make the dialog modeless and a child of a frame window - for the parent frame window
you can register a class and create the window of that class.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hey thanks! I like this reply better than maybe those that have just posted the acerbic definition answer.
In Spy++, i see that my dialog based app has Class name of #32770 (or something like that). But then again there can/are numerous "#32770" classed-windows out there at anygiven time and thus makes my "FindWindow(classname,title)" pretty much useless.
On that note too, "title" can't be assumed in my case as the app is putting a dynamic string in "title" for differernt operational conditions. for me.
I guess I will have to study another way of Posting messages to this dialog based app (too much involved for re-write to frame window....)
Thanks again,
Johnny
|
|
|
|
|
I have a video chat project.I use DirecxShow to capture video frames and udp to translate the video data.In the project,I use WM_TIMER message(using SetTimer() of cource)to capture a video frame and send it each second.
But I find,my program exhaust almost all the CPU recouce up to 98 percent or more.
And in another hands,I had a look at other video chat products,they only using 1 to 3 persent of CPU.
Some body would tell me why,and how to resolve it?
GOOD LUCK
|
|
|
|
|
Are you spinning in a loop on a thread somewhere?
What is the timer interval?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Yes,I spinned in a loop on a thread to retrieve data packages from network.But I have no choice.(client).
In the timer,I capture a video frame and send it each second.
|
|
|
|
|
In that loop, are you using sockets? If so, are you using a blocking socket that blocks until
data is received? If not then that will use nearly all your CPU.
For the timer, that's one frame per second? Interval is 1000 milliseconds, right? If so, then
that takes about zero CPU
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
In the loop, I think it uses none-blocking socket.In fact,I use a RTP socket to do such thing.(JRTPlib.lib,I think you do know it).
I am sorry,for timer,I capture a video fram and send it each 200 millisecond.
|
|
|
|
|
The thread with the communication loop would be much more efficient if it was event driven.
If it's just spinning, it's spending most of its CPU cycles doing nothing.
You may want to look into using WSAEventSelect() and waiting on an event indicating there's data
available to be read on the socket.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
I think you do know jrtplib,it doesn't give a event handle,so I could not using such way.
|
|
|
|
|
kcynic wrote: I think you do know jrtplib
Actually I've never heard of it but I'll take a look at it.
Without seeing your code I can't imagine where to start, but I still suspect the problem would be
in the communication loop. Your 200ms timer shouldn't be the problem unless you're doing an
extraordinary amount of stuff each interval.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
hi
with the following declarations:
void* __cdecl operator new(size_t nSize, LPCSTR lpszFileName, int nLine);
void __cdecl operator delete(void* pData, LPCSTR lpszFileName, int nLine);
void __cdecl operator delete(void* pData);
in the following code:
char *p=new char[10], *q=new char;
delete[] p;
delete p;
the second version of operator delete (with only one argument) is called while the new operator declared with three arguments had been called.
why?
|
|
|
|
|
Dear all
how to build a cylinder using vc++ 6.0 or with OpenGL together? any one has such snippet, thanks a lot. too urgent!!!!!!! my email is lizhiyuan16@hotmail.com. need your help..
Li Zhiyuan
21/07/2007
|
|
|
|
|
What exactly is C runtime library, and what role does it play in loading a windows exe into the OS's memory ?
Vipin.
|
|
|
|
|
That's a biggy. The C runtime library is a bunch of code that extends C++ to allow you do do useful basic things like write to the console, allocate memory, format strings, get locale information, declare thread local variables, use excecptions, spawn other proceses, initialize static variables, access the command line passed to your program etc etc.
You either use it by linking dynamically to MSVCRT.dll in one of its incarnations or link in the code directly by linking to LIBC.lib or one of its variants. The reason for the various versions is different ones for Debug and Release and in the past different ones for single or multi threaded application.
Strictly speaking the C runtime is not involved in loading a windows exe but it does do a bunch of stuff, some mentioned above, in your exe before your code is actually called so it kind of looks like it's involved in loading. By the time your program hits WinMain or main it has probably run several hundred to several thousand lines of CRT code.
The thing that loads your exe is the PE (Portable Executable) Loader which lives somewhere in the Kernel (probably NTDll.dll these days). Once it has done its magic, setting up a process and related memory space for you and loading in your code it calls an entry point function which is a function with a well known siganture at a specific offset in the compiled code (The offset is stored in the PE header on the exe file ) If you use the CRT then that entry point will be something like mainCRTStartup depending in CONSOLE or GUI app type and UNICODE or ANSI build. The source of the CRT is on your system, if you chose to install it when you installed Visual Studio, and is worth a look. It's a big mess but a very educational big mess. Enjoy
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
I want to set forecolor of each item in listview control(repoort view) hwow to do that?
|
|
|
|
|
|
thanks 4 ur rply,
bt i want to change the forecolor of one or two items(detail view) not the entire items.
item priority
-------------------
item1 low
item2 high
item3 normal
item4 high
item5 low
i want to set forecolor of item2 nd item4 to red which has high priority.
-- modified at 5:12 Saturday 21st July, 2007
|
|
|
|
|
|
If you derived CListView and use of cusom message you can do it.
|
|
|
|