|
We must indicate the size of date when using Recevie() function, but how to peek the data size of input queue? sometimes we don't know what size is that current queue head data.
|
|
|
|
|
hi
you can use ioctlsocket function to find out how much data is available to read.
|
|
|
|
|
I split a window into two parts(left and right)using CSplitterWnd .I want to dynamically changing right view. I have a method, but it must destory last view and create the view i want.how can i change the right view and don't destory the view before
thanks!!!!!
|
|
|
|
|
|
i tried DeleteFile
it didnt work - perhaps it's just meant for "files" - not directory
norm
|
|
|
|
|
How about ::RemoveDirectory() ?
B.
|
|
|
|
|
Nice but you must have deleted all files and folders in it.
-> It seems to be a little recursive task.
Try this @ home. (B&B)
|
|
|
|
|
::SHFileOperation() is a good one!
Rickard Andersson@Suza Computing
C# and C++ programmer from SWEDEN!
UIN: 50302279
E-Mail: nikado@pc.nu
Speciality: I love C#, ASP.NET and C++!
|
|
|
|
|
How do you declare a pointer to a template?
I'm trying to make a clone of the CList class, and cannot figure out how they have defined the POSITION type.
in list.h (search for 'clist' in the MSDN library), it is defined thusly:
#define POSITION CNode<type>*
This works for all class methods of my CList and CNode, however when I try and use it in code I get a "TYPE undeclared" error.
Suggestions?
- Xavier
|
|
|
|
|
I hope I am answering this before CG.
Why do you have to reinvent the wheel? Use std::list
Best regards,
Alexandru Savescu
P.S. Interested in art? Visit this!
|
|
|
|
|
Learning purposes, although I haven't looked at std::list, maybe that will shed some light.
Thanks.
- Xavier
|
|
|
|
|
we are using ODBC api call to access a oracle database.
we are using VC++.
Anyone knows how to get the SQL string with the parameter markers (?) replaced by their actual value.
Even after executing the query, parameter markers are still visible.
The goal is to use the full query to log the execution plan to file.
help is appreciated.
|
|
|
|
|
Hi,
I have written the following code to avoid multiple instances of my application.
if(::FindWindow(NULL,_T("My app"))!=NULL)
{
CWnd *pWndPrev;
if (pWndPrev = CWnd::FindWindow(NULL,_T("My app")))
{
pWndPrev->SetForegroundWindow();
pWndPrev->SendMessage(WM_MYMSG,(WPARAM)0,0);
return 0;
}
}
If my application is already running,If i try to launch again for the first time works.But if i try to launch again
it shows some assertion failure in mfc42.dll.
Can nayone help me?
Regards
Neha
|
|
|
|
|
try this
CWnd pWndPrev = ::FindWindow(NULL,_T("My app"));
if (pWndPrev)
{
SetForegroundWindow(pWndPrev);
// or need a test with AfxMsgBox(...); or something else
//pWndPrev->SendMessage(WM_MYMSG,(WPARAM)0,0);
return 0;
}
Borland solution
----------------
HWND hWnd=FindWindow(NULL,"NetTimer 3");
if(hWnd)
{
BringWindowToTop(hWnd);
if(IsIconic(hWnd)) ShowWindow(hWnd,SW_RESTORE);
else SetForegroundWindow(hWnd);
if(BringWindowToTop(hWnd))
MessageBox(hWnd,msg,"NetTimer 3",MB_OK | MB_ICONEXCLAMATION);
else SetForegroundWindow(hWnd);
return 0;
}
Have nice day
Leedoriden ( FRANCE )
|
|
|
|
|
Thanks for the reply.
If i don't do any sendmessage or postmessage it works.
|
|
|
|
|
If all you want is to prevent multiple instances of your app, try this:
HANDLE MutexHandle;
BOOL IsAlreadyRunning()
{
MutexHandle = CreateMutex(NULL, TRUE, "YOURAPPNAME");
if(GetLastError() == ERROR_ALREADY_EXISTS)
{
return(true);
}
else
{
return(false);
}
}
void CloseThisInstance()
{
ReleaseMutex(MutexHandle);
CloseHandle(MutexHandle);
}
...
if(IsAlreadyRunning())
{
MessageBox(NULL, _T("The app is already running!"), _T("Your app name"), MB_OK);
}
else
{
}
...
CloseThisInstance();
Regards,
Rohit Sinha
|
|
|
|
|
If you're using MFC, here's all you need to put in the app's InitInstance:
static CMutex mutex(FALSE, "YOURAPPNAME");
if (::GetLastError() == ERROR_ALREADY_EXISTS)
return FALSE;
Regards,
Alvaro
Well done is better than well said. -- Benjamin Franklin
(I actually prefer medium-well.)
|
|
|
|
|
Can merge two floating into one tabbed also can split them into two....
Thanks!
Thanks!!
|
|
|
|
|
Can somebody help me how does a download manager work with the features like resuming a download, finding alternate urls for a specific file.
|
|
|
|
|
I use IsBadReadPtr and IsBadWritePtr quite a bit in my code and for the most part have not considered the issue of performance related to these functions. I know there is some cost to their use, but how I just don't know. I try not to use them in deep inner loops (like any other function call), but I am still interested to know the cost of these functions.
Does anyone know how they work and how costly they are in CPU cycles?
|
|
|
|
|
I only use it in assert-statements, so that a bad-pointer is detected during development.
In a production version I only check for NULL-pointers.
I have the impression (but I'm not sure anymore), that the function is quite efficient as long as the pointer is valid. If the pointer is invalid, an internal exception is thrown, which is caught by the IsBadReadPtr function. In that case, there is a lot of overhead handling the exception, which makes it much slower.
You could always try to execute IsBadReadPtr in a loop and see its effect on a valid and on an invalid pointer.
But ... even if IsBadReadPtr returns success, it does not mean that the pointer is a valid pointer in your context. Suppose your pointer once pointed to e.g. a window structure, but that one has been freed, and its memory is now being reused by another data structure. Your window-pointer will then point to valid memory, but not to a window-structure anymore, which will crash your application later (in the best case), or corrupt other memory, files or your database (in the worst case). Therefore I wouldn't rely on IsBadReadPtr alone.
Another trick that can be used is to store a checksum in the first [four] bytes of a structure (or class). That way, you can always check the first bytes of your structure to see whether it is the kind of struct you would expect.
I do this sometimes (only in development versions, again for performance reasons).
<marquee>Enjoy life, this is not a rehearsal !!!
|
|
|
|
|
Thanks for the info.
I guess I need to just perform some testing and see how well it performs. I am most concerned with the performance on valid pointers so the overhead of exceptions for bad pointers isn't really an issue for me.
The particular application which lead me to the question is a Windows NT service I have written which powers a web site. I use the IsBadReadPtr/IsBadWritePtr functions in the release builds to insure stability. You are correct that just because IsBadXXXPtr returns false does not mean that you have a valid object. I also use dog-tags (similar to your suggestion of a checksum except that there is a tag at the beginning and the end of the class/struct) on the important structures and classes and validate them before accessing their data, again to insure stability.
I think I will do some performance testing and write an article on the results.
|
|
|
|
|
I split a window into two parts(left and right)using CSplitterWnd .I want to dynamically changing right view. I have a method, but it must destory last view and create the view i want.how can i change the right view and don't destory the view before
thanks!!!!!
|
|
|
|
|
I've run Depends on my application and determined that it needs:
mfc42.dll
msvcrt.dll
msvcp60.dll
wsock32.dll
shell32.dll
1. Am I allowed to redistribute these files?
2. Is it wise to redistribute these files? shell32.dll is 8M! Can I assume that a reasonable system will have a recent shell32.dll?
J
May the bear never have cause to eat you.
|
|
|
|
|
See REDIST.TXT in your VC 6 directory for a list of files you can redistribute. IIRC WinSock has its own installer which you can redistribute.
I should point out that it will save you a huge amount of headaches if you statically link to MFC. That way you don't have to redistribute the huge DLLs, nor worry about what happens if the machine has a newer version of the DLLs (will it break your code? probably not, but you never know; why risk it?).
Jamie Hale wrote:
Can I assume that a reasonable system will have a recent shell32.dll?
Absolutely not. Beginning with 98 and 2000, each OS has one and only one version of shell32. 95 and NT 4 can have one of three different versions depending on whether they have the Active Desktop shell installed.
--Mike--
"Adventure. Excitement. A Jedi craves not these things."
-- Silent Bob
1ClickPicGrabber - Grab & organize pictures from your favorite web pages, with 1 click!
My really out-of-date homepage
Sonork-100.19012 Acid_Helm
|
|
|
|