|
MarkSalsbery wrote: I'll let you decide if that's simple or not
well said,but it needs to a powerful compiler for decide about it
|
|
|
|
|
brahmma wrote: Apart from spam and abuse, we need a "Report crap" link!
i second you on that!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
BOOL bValue;<br />
<br />
if (bValue)<br />
{<br />
bValue = FALSE;<br />
}<br />
else<br />
{<br />
bValue = TRUE;<br />
}
If write this code to InterLocked functions, how to write?
if (InterlockedExchange(&bValue, TRUE) = TRUE))<br />
{<br />
InterlockedExchange(&bValue, FALSE);<br />
}
Right?
Thanks.
|
|
|
|
|
Currently, i am translating my VC++ 6.0 program into C++ program.
in my old VC++ program, i wrote an struct array into a file using
<br />
for(i = 0; i < struct_array_size; i++)<br />
{<br />
CFile::Write(&struct_address, sizeof(struct))<br />
}<br />
the struct is defined as
<br />
struct S{<br />
string Str;<br />
int Value;<br />
}<br />
Now, i wonder if there is an equivelent in standard C++ for CFile::Write().
Thanks,
|
|
|
|
|
All the same file I/O methods are still there. Are you trying to not use MFC?
The stdio functions (fopen, fread, fwrite, etc.)
The fstream classes
CAtlFile
CFile and derived
Windows APIs
etc.
Also, writing a string object like that - I don't think that will work (it may write but reading
it back in, I don't think so). It will write the object bytes but not the string contents.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Mark Salsbery,
thanks,
Yes, I am avoiding to use MFC classes.
Would you please be more detialed on how to use fstream class to implement my purpose.
Yes, i actually had problem with string item in the struct. Actually, I used char Name[20]. However, the length of the contents is varying. 20 is the max. length of the Name attribute of objects. Hence, memory was wasted by objects with a Name less than 20 characters. How to solve this problem.
Actually, I need a function in pure C++ framework to write/read the struct as a whole just as with CFile::Write() in VC.
|
|
|
|
|
cy163@hotmail.com wrote: Would you please be more detialed on how to use fstream class to implement my purpose.
#include <string>
#include <iostream>
using namespace std;
...
class S
{
string Str;
int Value;
public:
friend ostream& operator<< (ostream& os, S& s);
friend istream& operator>> (istream& is, S& s);
};
ostream& operator<< (ostream& os, S& s)
{
os << s.Str;
os.put('\n');
os.write((char *)&s.Value, sizeof(int));
return os;
}
istream& operator>> (istream& is, S& s)
{
is >> s.Str;
is.get();
is.read((char *)&s.Value, sizeof(int));
return is;
}
...
S s;
ofstream myfile("c:\\testmyfile.ext" , ios::binary : ios::trunc);
myfile << s;
...
S s;
ifstream myfile("c:\\testmyfile.ext" , ios::binary);
myfile >> s;
cy163@hotmail.com wrote: Yes, i actually had problem with string item in the struct. Actually, I used char Name[20]. However,
the length of the contents is varying. 20 is the max. length of the Name attribute of objects.
Hence, memory was wasted by objects with a Name less than 20 characters. How to solve this
problem.
I think there's some answers in your other post
cy163@hotmail.com wrote: Actually, I need a function in pure C++ framework to write/read the struct as a whole
Using the fstream classes will give you a OO, C++ way. You can make your class able to serialize
itself, as shown above.
Mark
-- modified at 1:44 Sunday 6th May, 2007
Fixed bonehead code
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Is it possible to have a custom icon size in the system tray?
I would like to be able to overlay a timer (hours:minutes) on top of my system tray icon, but due to the default size (16x16), there simply isn't enough room to display the timer in a visually appealing manner.
Thanks,
Adam
|
|
|
|
|
that would be a cool feature and i've often wanted to do the same.
but i haven’t found a method of doing so
i maybe wrong but i don’t think it is possible to have a icon greater than 16x16 in the sys tray.
|
|
|
|
|
TragicComic wrote: would like to be able to overlay a timer (hours:minutes) on top of my system tray icon, but due to the default size (16x16), there simply isn't enough room to display the timer in a visually appealing manner.
ythats typical .. you haev to redraw the system bar urself
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
How can I determine what is the version of the operation system for a program and the Service Pack? In vc6++.
36. When you surround an army, leave an outlet free.
...
Do not press a desperate foe too hard.
SUN-TZU - Art of War
|
|
|
|
|
GetVersionEx()
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
Thanks!
I'll try monday
36. When you surround an army, leave an outlet free.
...
Do not press a desperate foe too hard.
SUN-TZU - Art of War
|
|
|
|
|
Look at the following functions:
GetVersion()<br />
GetVersionEx()<br />
VerifyVersionInfo()
|
|
|
|
|
Thanks!
I'll try monday
36. When you surround an army, leave an outlet free.
...
Do not press a desperate foe too hard.
SUN-TZU - Art of War
|
|
|
|
|
brahmma
Covered the main ones
I had to do a similar class awhile back,
the function GetSystemMetrics(int); has two values which are useful
SM_MEDIACENTER and SM_TABLETPC
if you want anymore info about the system such as model
IWbemClassObject
good old WMI has a lot to offer.
p.s if your going to use GetVersionEx();
make sure your application fails safe if the wrong (unexpected) number returns
i know vista is new but wont be new forever
|
|
|
|
|
Thanks!
I'll try monday
In life it's very important the things to fail safe, if so.
36. When you surround an army, leave an outlet free.
...
Do not press a desperate foe too hard.
SUN-TZU - Art of War
|
|
|
|
|
RomTibi wrote: I'll try monday
why monday!??? any superstition
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hi
i have a class that makes a custom window,and at the WNDCLASS structure at
<br />
wc.lpfnWndProc=(WNDPROC)&CustomWindow::WndProc;<br />
i get the error:
<br />
error C2440: 'type cast' : cannot convert from 'LRESULT (__stdcall CustomWindow::*) (HWND,UINT,WPARAM,LPARAM)' to 'WNDPROC' There is no context in which this conversion is possible<br />
worked before in non class app as
<br />
wc.lpfnWndProc=WndProc;<br />
if someone could point out the problem or share a solution, it would be very apriciated.
|
|
|
|
|
To use a member function (method) as a callback like this, the method needs to be declared static.
That's because the OS knows nothing of your C++ object so it can't pass the implicit "this"
pointer that gets passed to non-static class methods.
Mark
"Posting a VB.NET question in the C++ forum will end in tears." Chris Maunder
|
|
|
|
|
Could you be more specific because im a noob
should i put static in front of my method declaration ?
Thanks for putting up with me in advance :P
|
|
|
|
|
|
shaderx wrote: should i put static in front of my method declaration ?
offcourse !
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
Hello,
I have problem and I am wandering if someone can help me with a solution. I have a windows service that works well and when it is stopped by the user the server should disable the proxy settings. There are 2 great samples on codeproject that are working well on changing the proxy settings for IE. So I have moved a method named DisableConnectionProxy which works in sample code but does not work in the service. So I know for sure that DisableConnectionProxy method disables the proxy settings in IE, the same code does not work (it is executed but does not change the proxy settings) when it is part of the service.
case SERVICE_CONTROL_STOP:<br />
DisableConnectionProxy("DefaultConnectionSettings")
I think that this might have something to do with the service interaction with the desktop. The service is running under the Local System Account.
If anyone has a suggestion or can recommend me a good article I would appreciate it.
Thanks.
|
|
|
|
|
Hello everyone,
I read OLE DB section from MSDN and it is mentioned that to implement an OLE DB provider is very simple and easy (is it true?). But from the minimal support function list, I find there are a lot of minimal functions. Not that easy!
I am wondering where can I find some tutorials (documents) about how to implement an OLE DB provider in C/C++?
thanks in advance,
George
|
|
|
|