|
Friends, at some point of my program execution, i want the memory consumption of my program (same value that we read from task manager). Any API solution that also work for Win 98 do tell me please ?
|
|
|
|
|
Shah Shehpori wrote:
i want the memory consumption of my program (same value that we read from task manager). Any API solution that also work for Win 98 do tell me please ?
Since when did Win98 get a Task Manager?
Whatever. Try GetProcessWorkingSetSize .
|
|
|
|
|
REQUIREMENT:: Application shud be sized to full monitor irrespective of the monitor size and current system resolution.
My APPLICATION:: Application is having four formviews in tabcontrol with many controls(AcitveX Lables and Buttons) on each forma view. My application is developed for best view in 15 inch and 800*600 resolution.
MY PROBLEM: i have written code to catch when resolution ic changed.and accorind to the new resolution m changing the each contols's client rect and moving the corresponding control to new client react. but reafreshing si becoming problem and some controls are painting over other controls.
adi narayana
|
|
|
|
|
I have a dialog based application with a group of 4 radiobuttons. I want one of 4 radiobutton to be active when form loads ?
So can i do it ??;P
|
|
|
|
|
i can't undesratnd what you want...but I guess you need to place the code for radiobuttons so as to make them active...when form loads..in OnInitDialog function...if it is a dialog based application..just put the code in InitInstance() that should do the work you want..
cheers
Himanshu
|
|
|
|
|
I'll just expand what Himanshu said :
First get a control to the button you want to active. Two ways to do it :
1.Add a control with the class wizard, let's name it m_FirstButton.
In the CMyDlg::OnInitDialog()
BOOL CMyDlg::OnInitDialog()
{
...stuff...
m_FirstButton.SetCheck(TRUE);
...stuff...
}
_or_
2.Get a control to it through the Index (IDC_...), like following :
BOOL CMyDlg::OnInitDialog()
{
...stuff...
CButton *firstbutton=(CButton*)GetDlgItem(IDC_FIRSTRADIOBUTTON);
firstbutton->SetCheck(TRUE);
...stuff...
}
And as Himanshu said, you can do some calculation also in the InitInstance (like processing the command line) if this is needed to chose which of your radiobutton should be active at startup.
~RaGE();
|
|
|
|
|
GetDlgItem is giving errors
CButton *firstbutton=(CButton*)GetDlgItem(IDC_FIRSTRADIOBUTTON);firstbutton->SetCheck(TRUE);
GetDlgItem' : function does not take 1 parameters
Error executing cl.exe.
|
|
|
|
|
Use a control-variable. You can make those with the Wizard, exactly like the Member variable, but you have to set the type to 'Control'.
Now, you have all options that the respective MFC-class offers.
Especially handy as your dialog grows.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
Just set your radio button member variable in dialog constructor. e.g.:
if your member variable is m_Options:
CDummyDlg::CDummyDlg()
{
m_Options = 0;
}
A. Riazi
|
|
|
|
|
Good Riazi that really worked !!!
|
|
|
|
|
Sorry, i had not thought that you could have used the value associated to your button (i prefer using controls). Riazi got me on this one.
~RaGE();
|
|
|
|
|
Hi all,
I want to delete the history, cache entries and cookies craeted by internet thru programming..Is there any good tutorial or can anyone guide me so as how to do it...Any thoughts and ideas are most welcome..
Thanks in advance..
Himanshu
|
|
|
|
|
Just call some shell function to retrieve folders of Temprory Internet Files and also History then delete all of files on it!
For more information on how to retrieve shell folders path, view my article: System Information[^].
A. Riazi
|
|
|
|
|
|
thanks buddy..this was what I was looking for....thans a lot..
cheers
Himanshu
|
|
|
|
|
i am using CALG_MD5 to encrypt/decrypt a string. it encryts the text but in decrypting it shows error "NTE_BAD_DATA" on lastblock other blocks are decrypted well. How can i resolve this erro.
Note:
final parameter is set to true for last block.
|
|
|
|
|
Zaid Ansari wrote:
am using CALG_MD5 to encrypt/decrypt a string
Are you sure you are using MD5 for encyrption/decryption? MD5 is an hash-algorithm so its result can't be "decrypted". Search the net for information about hashing vs. encrypting/decrypting. You could use algorithms like AES or DES for your needs.
--
karl
|
|
|
|
|
thanks karl,
i know that MD5 is a one way hash but i dont have any experiance in VC can u please tell me if i am making any mistake in this code.
to //code
if(!CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL,0))
{
}
// Create a hash object.
if(!CryptCreateHash(hCryptProv, CALG_MD5, 0, 0, &hHash))
{
strcat(strErrorMessage, "Error executing CryptCreateHash");
return NULL;
}
if(!CryptHashData(hHash, (BYTE *)password, strlen(password), 0))
{
strcat(strErrorMessage, "Error executing CryptHashData");
return NULL;
}
// Derive a session key from the hash object.
if(!CryptDeriveKey(hCryptProv, CONST_ENCRYPT_ALGORITHM, hHash, 0, &hKey))
{
strcat(strErrorMessage, "Error executing CryptDeriveKey");
return NULL;
}
// Destroy the hash object.
CryptDestroyHash(hHash);
hHash = 0;
// Determine number of bytes to encrypt at a time.
// This must be a multiple of CONST_ENCRYPT_BLOCK_SIZE.
// CONST_ENCRYPT_BLOCK_SIZE is set by a #define statement.
dwBlockLen = 10 - 10 % CONST_ENCRYPT_BLOCK_SIZE;
// get data block as close to 1000 bytes as possible making sure it's a multiple of ENCRYPT_BLOCK_SIZE
// Determine the block size. If a block cipher is used,
// it must have room for an extra block.
if(CONST_ENCRYPT_BLOCK_SIZE > 1)
dwBufferLen = dwBlockLen + CONST_ENCRYPT_BLOCK_SIZE;
else
dwBufferLen = dwBlockLen;
// Allocate memory.
pbBuffer = (BYTE *)malloc(dwBufferLen);
BYTE *pAllBlocks = NULL;
BYTE *pPreviousBlocks = NULL;
bool fMoreDataExists = true;
DWORD dwIndex = 0;
DWORD dwLength;
DWORD dwLengthOfEncryptedData;
DWORD dwAllBlocksLength, dwPreviousBlocksLength;
// Make way through data one block at a time. Find out how big
// each encrypted string will be, allocate memory for it, and save
// in array.
do
{
// get next block of clear text data
GetBYTEDataBlockFromString(dwIndex, pClearTextString, dwBlockLen, pbBuffer, dwLength);
// check if more data exists after current block
if (dwIndex >= strlen(pClearTextString))
fMoreDataExists = false;
// encrypt current data block
dwLengthOfEncryptedData = dwLength;
if(!CryptEncrypt(hKey, 0, !fMoreDataExists, 0, pbBuffer, &dwLengthOfEncryptedData, dwBufferLen))
{
fout<<"Error Occured in CryptEncrypt";
}
if (pAllBlocks)
delete [] pAllBlocks;
if (pPreviousBlocks)
dwAllBlocksLength = dwPreviousBlocksLength + dwLengthOfEncryptedData;
else
dwAllBlocksLength = dwLengthOfEncryptedData;
pAllBlocks = new BYTE[dwAllBlocksLength];
if (!pAllBlocks)
{
if(pbBuffer)
free(pbBuffer);
if (pPreviousBlocks)
delete [] pPreviousBlocks;
strcat(strErrorMessage, "Unable to allocate memory for pAllBlocks");
FreeAllCryptHandles(hKey, hHash, hCryptProv);
return NULL;
}
// copy all encrypted data to pAllBlocks
if (pPreviousBlocks)
{
CopyBYTEData(dwPreviousBlocksLength, pPreviousBlocks, pAllBlocks, dwAllBlocksLength, 0);
CopyBYTEData(dwLengthOfEncryptedData, pbBuffer, pAllBlocks, dwAllBlocksLength, dwPreviousBlocksLength);
delete [] pPreviousBlocks;
}
else
CopyBYTEData(dwLengthOfEncryptedData, pbBuffer, pAllBlocks, dwAllBlocksLength, 0);
if (fMoreDataExists)
{ // save previous data blocks for next iteration of this do loop
dwPreviousBlocksLength = dwAllBlocksLength;
pPreviousBlocks = new BYTE[dwPreviousBlocksLength];
if (!pPreviousBlocks)
{
if(pbBuffer)
free(pbBuffer);
if (pAllBlocks)
delete [] pAllBlocks;
strcat(strErrorMessage, "Unable to allocate memory for pPreviousBlocks");
FreeAllCryptHandles(hKey, hHash, hCryptProv);
return NULL;
}
else
CopyBYTEData(dwAllBlocksLength, pAllBlocks, pPreviousBlocks, dwPreviousBlocksLength, 0);
}
}
while(fMoreDataExists);
|
|
|
|
|
can any one send me code for encryption/decryption string using DES.
|
|
|
|
|
It's not DES, but it uses the Windows-CryptAPI.
On the other hand I'm quite sure there is a class outside in the wild which provides DES-encryption.
<br />
HCRYPTPROV hCryptProv;<br />
HCRYPTKEY hKey;<br />
HCRYPTHASH hHash;<br />
<br />
if ( !CryptAcquireContext(&hCryptProv, NULL , NULL, PROV_RSA_FULL, 0))<br />
AfxMessageBox("Error Acquire");<br />
<br />
if ( !CryptCreateHash(hCryptProv, CALG_MD5, 0, 0, &hHash))<br />
AfxMessageBox("Error CreateHash");<br />
<br />
if ( !CryptHashData(hHash, (BYTE*) "YourKey", (DWORD)strlen("YourKey"), 0))<br />
AfxMessageBox("Error Hashing");<br />
<br />
if ( !CryptDeriveKey(hCryptProv, CALG_RC4, hHash, 0, &hKey))<br />
AfxMessageBox("Error Derive Key");<br />
<br />
BYTE* buf;
DWORD size = (DWORD)strlen((char*)buf);<br />
<br />
CryptEncrypt(hKey, NULL, TRUE, 0, (BYTE*)buf, &size, size);<br />
<br />
CryptDecrypt(hKey, NULL, TRUE, 0, (BYTE*)buf, &size)<br />
<br />
This works fine for me. It's not a high-security app, so i hardcoded the encryption-key in the code. I simply took the Class-Name as key.
Hope I could help.
--
karl
|
|
|
|
|
i need simple DES encryption / decryption with hardcoded key. Thanks a lot Karl i will try this.
|
|
|
|
|
Thanks a lot Mr.Karl, it worked but now i have data which contanis 300 character but it encrypts forst 56 characters only. can u please tell me how can i do this both encryption and decryption.
|
|
|
|
|
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/security/Security/cryptencrypt.asp
--
karl
|
|
|
|
|
thanks karl,
i have 2 questions.
1. i implemented that code it encrypts first 56 characters 8 in each cryptencrypt call on next call it founds "space character" as first character in block it can not encrypt it,next blocks are encrypted but not added to result just because of "Space character".
How can i resolve this problem.
and my next question is that i am writing this code to be a platform independent can i implement same encryption/decryption in jave,
i will encrypt text in VC and Decrypt it in Java and vice versa.
can u please send me some sample code for block cipher and stream cipher.
if i nned to use some other algorithm than can u please send some sample.
Zaid
|
|
|
|
|
If I have a double type field in a jet database and the value 8.95 stored in it then when I retrieve it from the database as a string representaion it gives me "8.9499999999999993"
Is this just because the double type cannot represent the value 8.95 exactly? I have noticed that not all values come back as a huge string, e.g. 10.99, 1.95, and 8.5 are all exactly as entered. Or is it a bug with the code in the database driver that is doing the conversion?
|
|
|
|
|