|
I believe that this is the default behavior for COM Servers.
You can check the command line to see if you are being launched normally (no /Embedding or /Automation parameters), and manually bump your internal COM reference/instance count once. That will prevent unloading when a COM client connects (bumping the instance count) and disconnects (decrementing the instance count), because your instance count will still be above zero. You can use the CCommandLineInfo object used in your app's initialization and checks its members.
Be sure to also manually decrement the count when the user manually shuts your app down so that it unloads correctly, or your app will hide but keep running in the background.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
I have an OpenMutex() api call which I have fished out of a decompiled dll. The access rights member in the call is 0x00100000 . I have looking through the winnt.h header file trying to figure out which definition this would equate to, but I just cannot see it in there. Does anybody know what it is?
|
|
|
|
|
some times they might have made a custom security descriptor..
nave
|
|
|
|
|
SYNCHRONIZE (0x00100000L)
The right to use the object for synchronization. This enables a thread to wait until the object is in the signaled state.
Link[^]
Last modified: 2mins after originally posted -- link added
I don't believe in failure. It is not failure if you enjoyed the process.
|
|
|
|
|
Ahh thanks for that. I did see that macro, but MSDN was throwing me off a little.
|
|
|
|
|
I want to have a class in two namespace . If you know how its possible , please share with me .
In other word :
<br />
namespace A<br />
{<br />
class cls1<br />
{<br />
public:<br />
cls1()<br />
{<br />
};<br />
}<br />
}<br />
<br />
namespace B<br />
{<br />
????????
}<br />
<br />
main()<br />
{<br />
A::cls1 var1;<br />
B::cls1 var2;<br />
}<br />
<br />
Thanks a lot .
|
|
|
|
|
put the same thing in namespace B what u mentioned in namespace A
never say die
|
|
|
|
|
No in that case , class B::cls1 isn't same A::cls1 . (It is differ with A::cls1 ).
thanks .
|
|
|
|
|
Why do you want to do such a thing ??
It is probably a bad design, unless the two namespaces are nested.
|
|
|
|
|
I have a class that in conceptual model is in two namespace .
|
|
|
|
|
I cannot understand why do you want to do that. Anyway a (poor, I agree...) workaround maybe
namespace B
{
class cls1 : public A::cls1
{
};
};
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.
|
|
|
|
|
You should be able to put whatever class def you want into namespace B . What exactly are you worried about?
namespace A
{
class cls1
{
public:
cls1()
{
};
void ThisFunc1()
{
};
}
}
namespace B
{
<CODE> class cls1
{
public:
cls1()
{
};
void AnotherFunc42()
{
};
}</CODE>
}
main()
{
A::cls1 var1;
<code> B::cls1 var2;</code>
var1.MyFunc1();
<code> var2.AnotherFunc42();</code>
} Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
me think you cannot share a class between 2 namespace.
|
|
|
|
|
Might depend on what you mean by "share"... I think the following should work:
namespace A
{
class cls1
{
public:
cls1()
{
};
void ThisFunc1()
{
};
}
}
namespace B
{
<CODE> class cls1
{
public:
cls1()
{
};
void AnotherFunc42()
{
m_cls1FromA.ThisFunc1();
};
A::cls1 m_cls1FromA;
}</CODE>
} Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
Those will be 2 distinct and different classes in 2 namespaces.
If I understood the original post, the guy wanted to start his class declaration in one namespace and continued it in the second namespace.
|
|
|
|
|
Yes, but one shares the other - but I could misunderstand what the OP is talking about.
Peace!
-=- James If you think it costs a lot to do it right, just wait until you find out how much it costs to do it wrong! Avoid driving a vehicle taller than you and remember that Professional Driver on Closed Course does not mean your Dumb Ass on a Public Road! DeleteFXPFiles & CheckFavorites (Please rate this post!)
|
|
|
|
|
It's not clear from your question, but I think you want to have the class A::cls1 also visible in namespace B . If that's right, do this:
namespace A {
class cls1 { ... };
}
namespace B {
using A::cls1;
}
|
|
|
|
|
Thanks very much .
Your guide is what I search for .
|
|
|
|
|
I attatched one imagelist along with the listCtrl.
And showed those images to the list view successfully.
But how to change these icons chaged dynamicaly to the list view?
|
|
|
|
|
Use SetItem function and specify the Mask as LVIF_IMAGE
Used on me in a bar: Have you considered suing your brains for non-support?
|
|
|
|
|
How to place text and icon together in a ToolBarCtrl(Dialog based application)?
|
|
|
|
|
Hallo,
I would like to get a mouse event when my console application is running. Under http://www.codeproject.com/shell/taskbaricon.asp is a nice solution but I need to get the mouse event although i did not click on the systray icon. A global mouse event listener in other words.
Thanks a lot for your help. I hope you can understand my English.
|
|
|
|
|
Have a look at the SetWindowsHookEx() function.
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
I am trying to build a cryptography program using HMACSHA256 as the verification technique. I came across this article by Nathan Blomquist and here's the link:
File Encryption/Decryption with Hash Verification in C#
http://www.codeproject.com/csharp/fileencryptdecrypt.asp
I edited the code to use HMACSHA256 instead as well as C++. Upon decryption using the incorrect password, I will encounter this error.
An unhandled exception of type 'System.Security.Cryptography.CryptographicException' occurred in mscorlib.dll
Additional information: Padding is invalid and cannot be removed.
Below is my code and the error occurs at this line
while ( (bytesInCurrentBlock = cin->Read(buffer, 0, buffer->Length)) != 0 )
in the DecryptFile function. I would be grateful if someone could point out my mistake here.
PS: I am suppose to be expecting the hmacsha256 mismatch error to throw instead
<code>void CryptoData::EncryptFile(String^ inFile, String^ outFile, String^ password, int keySize,
CryptoProgressCallBack^ callback)
{
FileStream^ fin = gcnew FileStream(inFile, FileMode::Open, FileAccess::Read);
FileStream^ fout = gcnew FileStream(outFile, FileMode::OpenOrCreate, FileAccess::Write);
fout->SetLength(0);
array<Byte>^ buffer = gcnew array<Byte>(BUFFER_SIZE);
int bytesInCurrentBlock;
long long bytesProcessed = 0;
long long fileLength = fin->Length;
long progress;
// generate IV and Salt
array<Byte>^ IV = GenerateRandomBytes(16);
array<Byte>^ salt = GenerateRandomBytes(16);
// create the crypting object
SymmetricAlgorithm^ sma = CreateRijndaelManaged(password, keySize, IV, salt);
// write the IV and salt to the beginning of the file
fout->Write(IV, 0, IV->Length);
fout->Write(salt, 0, salt->Length);
// Initialize the keyed hash object.
HashAlgorithm^ hmacsha256 = gcnew HMACSHA256(sma->Key);
// Compute the hash of the input file.
array<Byte>^ hashValue = hmacsha256->ComputeHash(fin);
// Reset fin to the beginning of the file.
fin->Position = 0;
// Write the computed hash value to the output file.
fout->Write(hashValue, 0, hashValue->Length);
// create the cryptostream
CryptoStream^ cout = gcnew CryptoStream(fout, sma->CreateEncryptor(), CryptoStreamMode::Write);
// read and write the bytes to the crypto stream in BUFFER_SIZE chunks
while ( (bytesInCurrentBlock = fin->Read(buffer, 0, buffer->Length)) != 0 )
{
cout->Write(buffer, 0, bytesInCurrentBlock);
bytesProcessed += bytesInCurrentBlock;
progress = (int)((bytesProcessed / fileLength) * 100);
callback(0, 100, progress);
}
// clear the hashing object
hmacsha256->Clear();
// flush and close the cryptostream
cout->Flush();
cout->Close();
// close the input file
fin->Close();
}
void CryptoData::DecryptFile(String^ inFile, String^ outFile, String^ password, int keySize,
CryptoProgressCallBack^ callback)
{
FileStream^ fin = gcnew FileStream(inFile, FileMode::Open, FileAccess::Read);
FileStream^ fout = gcnew FileStream(outFile, FileMode::OpenOrCreate, FileAccess::Write);
fout->SetLength(0);
array<Byte>^ buffer = gcnew array<Byte>(BUFFER_SIZE);
int bytesInCurrentBlock;
long long bytesProcessed = 0;
long long fileLength = fin->Length;
int progress;
// read the IV and Salt
array<Byte>^ IV = gcnew array<Byte>(16);
fin->Read(IV, 0, 16);
array<Byte>^ salt = gcnew array<Byte>(16);
fin->Read(salt, 0, 16);
// create the crypting object
SymmetricAlgorithm^ sma = CreateRijndaelManaged(password, keySize, IV, salt);
// Initialize the keyed hash object.
HashAlgorithm^ hmacsha256 = gcnew HMACSHA256(sma->Key);
// Create an array to hold the keyed hash value read from the file.
array<Byte>^ storedHash = gcnew array<Byte>(hmacsha256->HashSize / 8);
// Read in the storedHash.
fin->Read(storedHash, 0, storedHash->Length);
bytesProcessed = 64;
// create the cryptostream that will process the file
CryptoStream^ cin = gcnew CryptoStream(fin, sma->CreateDecryptor(), CryptoStreamMode::Read);
// read the BUFFER_SIZE chunks
while ( (bytesInCurrentBlock = cin->Read(buffer, 0, buffer->Length)) != 0 )
{
fout->Write(buffer, 0, bytesInCurrentBlock);
bytesProcessed += bytesInCurrentBlock;
progress = (int)((bytesProcessed / fileLength) * 100);
callback(0, 100, progress);
}
// Reposition the file to compute the hash of the output file.
fout->Position = 0;
array<Byte>^ computedHash = hmacsha256->ComputeHash(fout);
if (!ByteArrayEqual(computedHash, storedHash)) {
throw gcnew CryptoDataException("hmacsha256 mismatch");
}
// flush and close the cryptostream
cin->Flush();
cin->Close();
// close the output file
fout->Close();
}
</code>
-- modified at 5:09 Wednesday 20th December, 2006
|
|
|
|