|
yes it does... but you would have used your debugger and you'd have figured that out yourself
|
|
|
|
|
while using Threads against Multimedia timer when stoping threads in function i got Following Exception
First-chance exception in Nova.exe(NTDLL.DLL):0xC00000008:Invalid Handle
the code in method is
void Cvep::stoprecThread()
{
KillTimer(4);
KillTimer(5);
CSingleLock lock1(&c_s0);
lock1.Lock();
recflag=0;
lock1.Unlock();
PatternsFinish();
ResumeThread(hand[1]);
ResumeThread(hand[0]);
DWORD lpExitCode0;
DWORD lpExitCode1;
::GetExitCodeThread(hand[0], &lpExitCode0);
::GetExitCodeThread(hand[1], &lpExitCode1);
if(STILL_ACTIVE == lpExitCode1 )
{
WaitForSingleObject(hand[1], INFINITE);
}
if(STILL_ACTIVE == lpExitCode0 )
{
WaitForSingleObject(hand[0], INFINITE);
}
CloseHandle(hand[1]);
CloseHandle(hand[0]);
}
plz help how to resolve this
|
|
|
|
|
- What is the line wherein the error occurs?
- Why don't you check
::GetExitCodeThread return value?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi all.
I uesd FSCTL_GET_VOLUME_BITMAP to get free cluster list but When bitmap is very large it can not be fit into buffer, So I tried to read the bitmap in small chunks of bytes but I am always getting the bitmap from startting 0 offset, How could I read bitmap in small chunks.
my code is here, Please correct if i am wrong
BOOL CFreeCluster::GetBitmap()
{
STARTING_LCN_INPUT_BUFFER StartingLCN;
VOLUME_BITMAP_BUFFER *Bitmap = NULL;
ULONGLONG BitmapSize;
DWORD BytesReturned;
BOOL Result;
StartingLCN.StartingLcn.QuadPart = 0;
BitmapSize = sizeof (VOLUME_BITMAP_BUFFER) + 4;
Bitmap = (VOLUME_BITMAP_BUFFER *) malloc (BitmapSize);
HANDLE hHandle=OpenDrive();
Result = DeviceIoControl
(
hHandle,
FSCTL_GET_VOLUME_BITMAP,
&StartingLCN,
sizeof (StartingLCN),
Bitmap,
BitmapSize,
&BytesReturned,
NULL
);
if (Result == FALSE && GetLastError () != ERROR_MORE_DATA)
{
free (Bitmap);
return (false);
}
BitmapSize = (Bitmap->BitmapSize.QuadPart / 8) + 1;
int nBufferSize=8*512*3;
ULONGLONG ullItr=BitmapSize/nBufferSize;
if(BitmapSize%nBufferSize!=0)
ullItr++;
Bitmap = (VOLUME_BITMAP_BUFFER *) realloc (Bitmap, nBufferSize+1);
for (ULONGLONG ullTmp=0; ullTmp < ullItr; ullTmp++)
{
if(BitmapSize < nBufferSize)
nBufferSize=BitmapSize;
StartingLCN.StartingLcn.QuadPart=ullTmp*nBufferSize;
Result = DeviceIoControl
(
hHandle,
FSCTL_GET_VOLUME_BITMAP,
&StartingLCN,
nBufferSize,
Bitmap,
nBufferSize,
&BytesReturned,
NULL
);
BitmapSize=BitmapSize-nBufferSize;
}
}
return (true);
}
|
|
|
|
|
Hi All,
Iam having 3 tree controls.Now i need to access Drag and Drop between 2nd and 3rd only.I need some sample code for this.Its very urgent for me.
Plz help me.........
Thanks & Regards,
Anitha
|
|
|
|
|
For drag & drop you need to OnBeginDrag and OnLButtonUp.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
I have coded the following:
---------------------------------------------
//file BT01.h
class BT01
{
public:
int BruteForce(char *P, char *T);
void InputText(char *T, char *P);
};
---------------------------------------------------
//file BT01.cpp
#include "BT01.h"
#include "time.h"
#include "dos.h"
#include <iostream>
#include <conio.h>
#include <stdio.h>
using namespace std;
int BT01::BruteForce(char *P, char *T)
{
//duyet T
for (int i = 0; i <= strlen(T) - strlen(P); i++)
{
//khai bao j
int j = 0;
//duyet P
while (j < strlen(P))
{
//Kiem tra ptu tai T tai vi tri thu i + j co bang j hay khong? xu ly
if (tolower(T[i + j]) == tolower(P[j]))
j++;
else
break;
}
//Tim thay
if (j == strlen(P)) return i;
}
//khong tim thay
return -1;
}
void BT01::InputText(char *T, char *P)
{
do{
printf("T: ");
gets(T);
}
while (strlen(T) < 1);
do{
printf("P: ");
gets(P);
}
while(strlen(P) < 1 || strlen(P) > strlen(T));
}
void main()
{
char *P = new char[20];
char *T = new char[999];
printf("BAI TAP TH01 - THUAT TOAN BRUTEFORCE\n");
BT01 objBT01;
objBT01.InputText(T, P);
int kq;
kq = objBT01.BruteForce(P, T);
if (kq == -1)
printf("KQ: Khong tim thay.");
else
printf("\nKQ: %i, %i", kq, strlen(T));
printf("\nThoi gian (ms): ");
getch();
}
I would like to count time for Algorithm BruteForce. How to count?
modified on Monday, December 22, 2008 11:00 PM
|
|
|
|
|
I'm not sure what you mean by "count time". If you mean algorithmic complexity, the worst case running time would be O((T - P + 1) * P) because that's the maximum number of times the loops in BruteForce together can execute. A little calculus also shows that the worst occurs when P = (T + 1) / 2, in which case the running time would be O(T2).
If you're looking to calculate the actual running time of the function, you should use a library function such as clock()[^] to get the time before and after calling the BruteForce function - then the difference in those times will give you the execution time.
|
|
|
|
|
hi,
when i quit my program in debug mode, the compiler pups up a dialog:Unhandled exception in **.exe, 0xc0000005:Access Vialation. and the disassemble codes are:
014BAFE6 53 push ebx
014BAFE7 56 push esi
014BAFE8 57 push edi
014BAFE9 51 push ecx
014BAFEA 8D 7D B8 lea edi,[ebp-48h]
014BAFED B9 12 00 00 00 mov ecx,12h
014BAFF2 B8 CC CC CC CC mov eax,0CCCCCCCCh
014BAFF7 F3 AB rep stos dword ptr [edi]
014BAFF9 59 pop ecx
014BAFFA 89 4D FC mov dword ptr [ebp-4],ecx
014BAFFD 8B 45 FC mov eax,dword ptr [ebp-4]
014BB000 C7 40 0C 00 00 00 00 mov dword ptr [eax+0Ch],0
014BB007 8B 4D FC mov ecx,dword ptr [ebp-4]
014BB00A C7 41 1C 10 00 00 00 mov dword ptr [ecx+1Ch],10h
014BB011 8B 55 FC mov edx,dword ptr [ebp-4]
014BB014 8B 42 1C mov eax,dword ptr [edx+1Ch] //err place: 014bb014() line 6277 + 3 bytes
014BB017 83 E0 01 and eax,1
014BB01A 85 C0 test eax,eax
014BB01C 0F 85 AE 00 00 00 jne CDiskCheck::TaskProcess+0F0h (014bb0d0)
anybody know the problem? thank u!!
|
|
|
|
|
since we cant re-assemble this disassemly, how about you post the actual CODE causing the issue !!!
'g'
|
|
|
|
|
because i did the "go to source" cannot go to the source code...
the "call stack" info:
***! 014bb014() line 6277 + 3 bytes
***! 014baba0() line 6111
KERNEL32! 7c80b713()
|
|
|
|
|
well, you've lost me .. but I can tell you that its a pointer issue - either you've used a NULL pointer or you're overwriting a pointer/some area of memory or such ..
if there's someone more experienced around they may be able to help more by looking at the trace, but its a big ask without source code
'g'
|
|
|
|
|
hi,
although i really want to know the exact causion,
thank u all the same.
|
|
|
|
|
My brain must be mushed. I'm hoping to get back into real programming after a brief spell of not doing any, then doing a Python project at uni, and I would like to get into C++ - since it is a Games course.
Every tutorial or article on callbacks (so far, not many) that I've read, I get the basic idea - then lose it.
Possibly my experience in C# with objects is screwing my mind up...
Can anyone recommend a good, short, simplified tutorial on a basic callback (just a proof-of-concept tutorial, preferably not solving any real problems).
Or even "post teh codes plox"?
In the meantime I think I'll read some more C++ guides.
Ninja (the Nerd)
Confused? You will be...
|
|
|
|
|
Write a program using EnumWindows [^]. A succesfull usage of such function will remind you about callback concepts for all your life.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Hi,
This app is in C++ without MFC, and I'm using SetWindowSubclass to subclass two of my windows controls so that I can manually catch the messages that are sent to their message pumps and process them accordingly. The app is dialog-based and uses a GetMessage loop, so it does not usually take much CPU power... however, the problem is this:
when I call SetWindowSubclass to subclass either of the controls, suddenly my CPU usage jumps to 99% on the task manager. Does SetWindowSubclass branch a new thread for each control that will just run on its own regardless of my GetMessage loop? If so, how do I stop it from doing that? If not, what the heck is it doing and how can I use SetWindowSubclass without using 99% of my darned CPU?
Thanks!
KR
|
|
|
|
|
KellyR wrote: Does SetWindowSubclass branch a new thread for each control that will just run on its own regardless of my GetMessage loop?
No it wont start any new thread. If possible show the code that calls the SetWindowSubclass() fucntion and also the claabck function that you passed to SetWindowSubclass.
|
|
|
|
|
I see what happened, I was returning in my WM_PAINT messages which was causing the huge CPU usage. I guess the DefSubclassProc must do something with WM_PAINT that causes the message not to be sent again; maybe by returning and not setting this parameter, the WM_PAINT was getting sent continuously.
Thanks for help!
KR
|
|
|
|
|
KellyR wrote: ...maybe by returning and not setting...
"Maybe"?
When working with window messages, you will have much better results if you
are sure about how to handle the messages, including proper return values.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
I am developing an VC application.
Whenever the user cliks on the exe, first the password dialog is to
be opened for user authentification.
So where can I store the password.
I am thinking about storing it in Registry.But is it the correct way of
storing the password?
Please clarify.
Regards,
Sunil Kumar
|
|
|
|
|
sunilkumar.d wrote: I am thinking about storing it in Registry.But is it the correct way of
storing the password?
I think you're confusing 'where to store' a password with 'how it should be stored' .. a password should never be stored anywhere as plain text - you should hash it with something like sha1 and store the hash [at a minimum]. When the user enters the password, you hash that and compare it to the stored hash and if there are the same, they are allowed access ...
Now, as to where to actually store the hashed/encrypted/obfuscated password - that depends on a lot of things .. will the password change and how often ? How will you handle updates - what happens if some other user needs to run the program from their PC ?? (etc etc) In the end, you must evaluate these questions vs how important the data/program is should it get into the wrong hands ..
.. and for anything but a trivial app I'd recommend looking at USB keys that you can issue to each user - then you have ultimate control
'g'
|
|
|
|
|
you can store the password in the registry, but there is a problem with that,you cant run in another computer. the best way is to store in a file or in a database.
|
|
|
|
|
Well there are many nice tricks!
as the friends said:
you can store it in registry (this is not the best way)
as you can store it in a database:
if your application uses databases, the best way is to create a table named SECURITY in which you put the password
another nice way is to put it in a file and give it System, Hidden attributes!, BUT in this you should encrypt your password (1)..
(1) there are easy ways to encrypt passwords or strings in general! just increment the ASCII code of all the characters by a value that you define (30 for example) in encryption function, and decrement it bye the same value in the decryption function, and you should put some rules (ASCII code 255 + 1 = 0, 255 + 2 = 1 ..)
--------------------------------------------
Some people dream of success while others wake-up and work hard to get it!
|
|
|
|
|
Hi All,
When i am porting a VC++ 6.0 application to VC++ 9.0, i am getting a assertion in keyboard handeller.
This is what i ma doing.
Mapping the function keys F1 thru F12 to bialog buttons. There is no assertion when i press F1 thru F11, but when i press the F12 key to activate that particular buttion, this is the message that is popping up with assertion.
"Windows has triggered a breakpoint in application.exe.
This may be due to a corruption of the heap, which indicates a bug in application.exe or any of the DLLs it has loaded.
This may also be due to the user pressing F12 while application.exe has focus.
The output window may have more diagnostic information."
Code:
CKeyDef *CKeyboardCtrl::HandleKeyboardMsg(MSG *pMsg)
{
UINT msgCode = pMsg->message;
switch (msgCode) {
case WM_SYSKEYDOWN:
msgCode = WM_KEYDOWN;
break;
case WM_SYSKEYUP:
msgCode = WM_KEYUP;
break;
}
ASSERT(msgCode == WM_KEYDOWN || msgCode == WM_KEYUP); //Assertion for F12
long keyCode = pMsg->wParam;
CKeyDef *pKey = LookupKeyCode(keyCode); //Assertion for F12
}
CKeyDef * CKeyboardCtrl::LookupKeyCode(long keyCode)
{
for (KeyList::iterator it=m_keyList.begin(); it != m_keyList.end(); it++) {
if (it->m_keyCode == keyCode)
return &*it;
}
return NULL;
}
Thanks Everyone.
|
|
|
|
|
F12 is debugger hotkey for breaking the execution. If you press F12 when your application is debugged, then debugger will catch it and break at current line of execution. Run your application standalone and your application will be able to catch F12. Nothing to worry that its expected behavior and not a porting bug.
To demo the F12 fact, Create a dialog application, run by F5, then take the dialog and press F12. The debugger will break to the current line of execution.
Regards,
Jijo.
_____________________________________________________
http://weseetips.com[ ^] Visual C++ tips and tricks. Updated daily.
|
|
|
|
|