|
Yeah you just rewminded me the other way to deal with the problem (probably more efficiant too) i this.
Say my function has to be have the parameters WPARAM followed by LPARAM, you don't have to give these names:
int Function2(WPARAM, LPARAM param2)
{
param2 += 6;
} You see the WPARAM is still present in the parameter list, but is not referenced at all. I think the optimiser should reduce the two methods to producing the same code, but this way is a little more elegant.
Joel Holdsworth
Wanna give me a job this summer?
Check out my online CV and project history[^] - now available in MSWord format![^]
|
|
|
|
|
Yea that’s how I send messages when I don’t need the first param (WPARAM).
It’s the params from over ridded messages that’s causing the problems.
-------------------------------
|
|
|
|
|
I've used
<br />
void Function(int param1, int param2)<br />
{<br />
UNREFERENCED_PARAMETER(param2);<br />
}<br />
and
<br />
void Function(int param1, int )<br />
{<br />
}<br />
I think there's another macro, can't remember it offhand.
Pssst. You see that little light on your monitor? That's actually a government installed spy camera. Smile and wave to big brother!
|
|
|
|
|
Jack Squirrel wrote:
void Function(int param1, int param2)
{
UNREFERENCED_PARAMETER(param2);
}
I like that one. Pretty clear that, that param is not used.
-------------------------------
|
|
|
|
|
Jack Squirrel wrote:
I think there's another macro, can't remember it offhand.
MFC's macros: "UNUSED" and "UNUSED_ALWAYS" will do that trick for you too
I also got the blogging virus..[^]
|
|
|
|
|
This is the best way thought
void Function(int param1, int /*param2*/)
{
}
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Papa wrote:
void Function(int param1, int /*param2*/)
{
}
Yea know some how I bet your correct.
Anyone else know for sure?
Thx Much
-------------------------------
|
|
|
|
|
The bug slayer, John Robbins, in his Debugging Applications for Microsoft .NET and Microsoft Windows (Great book btw)
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Sounds good.
Now that I’m at home and free to wander the net I found an article at
http://msdn.microsoft.com/msdnmag/issues/05/05/CAtWork/default.aspx[^]
Which comments on this very subject. They say it doesn’t really matter. I’m inclined to think that commenting the section out is a "little" cleaner way to go about it (after some experimentation).
-------------------------------
|
|
|
|
|
I know that these macros often resolve to
param = param;
which is a junk code just to reference the param.
The commenting of the param just instruct the compiler to *not see* the param in order to skip the warning
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Is there a simple way I can find out how much memory (Private Bytes) my app currently has (in code, that is)
--
Help me! I'm turning into a grapefruit!
Buzzwords!
|
|
|
|
|
You can use the performance counters for this. Something like:
TCHAR szAvailBytes[256] = TEXT("");
TCHAR szCacheBytes[256] = TEXT("");
TCHAR szWorkingSet[256] = TEXT("");
TCHAR szBuffer[256] = TEXT("");
DWORD dwBufferSize = sizeof(szAvailBytes);
HCOUNTER hAvailBytes,
hCacheBytes,
hWorkingSet;
HQUERY hQuery = NULL;
PDH_COUNTER_PATH_ELEMENTS pdhCpe;
PDH_STATUS pdhStatus;
PDH_FMT_COUNTERVALUE pdhfmtAvail,
pdhfmtCache,
pdhfmtWorking;
pdhStatus = PdhOpenQuery(NULL, 0, &hQuery);
if (pdhStatus == ERROR_SUCCESS)
{
pdhCpe.szMachineName = TEXT("crow-nt");
pdhCpe.szObjectName = TEXT("Memory");
pdhCpe.szInstanceName = NULL;
pdhCpe.szParentInstance = NULL;
pdhCpe.dwInstanceIndex = -1;
pdhCpe.szCounterName = TEXT("Available Bytes");
pdhStatus = PdhMakeCounterPath(&pdhCpe, szAvailBytes, &dwBufferSize, 0);
pdhCpe.szCounterName = TEXT("Cache Bytes");
dwBufferSize = sizeof(szCacheBytes);
pdhStatus = PdhMakeCounterPath(&pdhCpe, szCacheBytes, &dwBufferSize, 0);
pdhCpe.szObjectName = TEXT("Process");
pdhCpe.szInstanceName = TEXT("_Total");
pdhCpe.szCounterName = TEXT("Working Set");
dwBufferSize = sizeof(szWorkingSet);
pdhStatus = PdhMakeCounterPath(&pdhCpe, szWorkingSet, &dwBufferSize, 0);
pdhStatus = PdhAddCounter(hQuery, szAvailBytes, 0, &hAvailBytes);
pdhStatus = PdhAddCounter(hQuery, szCacheBytes, 0, &hCacheBytes);
pdhStatus = PdhAddCounter(hQuery, szWorkingSet, 0, &hWorkingSet);
pdhStatus = PdhCollectQueryData(hQuery);
pdhStatus = PdhGetFormattedCounterValue(hAvailBytes, PDH_FMT_LONG | PDH_FMT_NOSCALE, NULL, &pdhfmtAvail);
pdhStatus = PdhGetFormattedCounterValue(hCacheBytes, PDH_FMT_LONG | PDH_FMT_NOSCALE, NULL, &pdhfmtCache);
pdhStatus = PdhGetFormattedCounterValue(hWorkingSet, PDH_FMT_LONG | PDH_FMT_NOSCALE, NULL, &pdhfmtWorking);
wsprintf(szBuffer, TEXT("Physical Mem = %ldMB\n"), (pdhfmtAvail.longValue + pdhfmtCache.longValue + pdhfmtWorking.longValue) / (1024 * 1024));
pdhStatus = PdhCloseQuery(hQuery);
}
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
You can open a handle to your process and use VirtualQueryEx to scan the memory usage for your program.
Examine the MEMORY_BASIC_INFORMATION.State and MEMORY_BASIC_INFORMATION.Type to accumulate the totals for the memory information that interests you.
You can make a function to find out how much memory is being used by executable code, how much is free, how much is comitted, how much is in memory mapped files, etc.
|
|
|
|
|
hi all,
well i'm developing a simple packet sniffer using winpcap in VC++ environment.. where packets are captured and filtered.... i'm able to filter using port no,ip address and protocol but what i'm suppose to do is to filter packets using process ID which i'm unable to do..so please any one can help me as soon as possible... thanks in advance
regards
sura
sura
|
|
|
|
|
You could use GetTcpTableEx()/GetUdpTableEx() to get a list of the TCP/UDP connections and their processes. Assuming your app is to run on minimum OS of XP, of course.
Alternativly ud need to develop a low level driver to do that.
|
|
|
|
|
Hi,
Recently i've seeing a lot of articles on DLL injection (injection code into another process or something like that). Can anyone tell em the uses of it and how it works? Just curious!
|
|
|
|
|
It's a very flexible teqnique. It essentially allows yor application to do things which arn't otherwise possible. For example in this project[^] i used code injection to deactivate the Ctrl+Alt+Delete key combo. I've seen code injection used to skin the windows tray clock: http://www.rcis.co.za/dale/tclockex/[^]. In both cases here code has been injected, and setup to hook into the WindowProc so that messages a routed through it to allow the code to extend or surpress standard functionality. The sky's the limit - use your imagination!
Joel Holdsworth
Wanna give me a job this summer?
Check out my online CV and project history[^] - now available in MSWord format![^]
|
|
|
|
|
How to get notified when user logoff?
WM_ENDSESSION & WM_QUERYENDSESSION messages are not OK. Cause the system won't send these messages when EWX_FORCE flag is set in ExitWindowsEx function.
Is there any way to get notified other than using dll in "HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\
CurrentVersion\Winlogon\Notify" entry?
Thanks a lot!
Let's roll!
|
|
|
|
|
Check out ISensLogon .
"Ideas are a dime a dozen. People who put them into action are priceless." - Unknown
|
|
|
|
|
Hi, I have a 11x5 bidimensional array of .net textboxes in my app. When the user paste into one of those textboxes, I want to parse the clipboard string, splitting it in 2length substrings and putting each substring in each textbox. Example:
I copy from a web page this string: "10 11 12 13 14". Then I paste (with mouse or ctrl-v) in the first textbox. I want the first text box take the "10" value, the second one the "11" value etc... etc... There also restrinctions of numbers (they must be >0 and <90 and not repeated for line) but I've already implemented those checks with some keyPress, controlLeave and controlEnter event handlers.
I have no clue wich is the best way to do it. Help.
|
|
|
|
|
Here What i would do
First Option
Subclass the first edit box
catch the WM_PASTE message
pass the string to the parent window
start processing the string
and set the edits acording to your specification
Or
Seconde Option
Add a button to that window
when you copy the text insted of passing it with ctr+v
push the button
Open the Clipboard read the text
praise it
and pass it to the specified edits;
I hope i could give you some clues.
G_S
|
|
|
|
|
Thanks for help. I've decided to go through the first way. Anyway I have a problem with passing the string to the parent window. Here's my code:
public __gc class myParentForm; // declared to allow double inclusion
// ...
// derived textbox class to allow custom paste from clipboard
public __gc class CustomPasteTextBox : public System::Windows::Forms::TextBox {
private:
const static int WM_PASTE = 0x302;
protected:
void WndProc(System::Windows::Forms::Message __gc* m){
switch(m->get_Msg()){
case WM_PASTE: // custom paste operation
if(Clipboard::GetDataObject()->GetDataPresent(DataFormats::Text)){
String* pastedString = Clipboard::GetDataObject()->GetData(DataFormats::Text)->ToString();
>>> (__try_cast<MyParentForm*>(this->get_Parent()))->customPaste(pastedString, this);
}
break;
default:
__super::WndProc(m);
break;
}
}
};
// ...
Compiler cannot convert from Control to my derived Windows Form, why?
|
|
|
|
|
Hey long time no see! Anywayz,
What would be the easiest way to get IDC_EDIT1 (total amount) be split into dollars and change...
IDC_EDIT1 (Total) = 1.50
IDC_EDIT2 (Dollars) = 1.00
IDC_EDIT3 (Change) = 0.50
How would i split 1.50 into 1.00 and 0.50?
Or how would i split $15.68 into $15.00 and 0.68?
Any help would b greatful, nice to see you all again!
/* Just a Human Trying to Live in a Computers World. */
|
|
|
|
|
if i understand correctly you wand this
double dTotalSize = 15.68;
<br />
int iDollar = (int)dTotalSize;<br />
double dCent = dTotalSize - iDollar;<br />
G_S
|
|
|
|
|
NewbieStats wrote:
How would i split 1.50 into 1.00 and 0.50?
Or how would i split $15.68 into $15.00 and 0.68?
float a=15.68;
IDC_EDIT2 (Dollars) = int(a);
IDC_EDIT3 (Change) = a-int(a);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|