|
Visual Leak Detector Version 2.2.3 installed.
No memory leaks detected.
Visual Leak Detector is now exiting.
The program '[9248] ProcEnum.exe' has exited with code 0 (0x0).
Not a false positive.
|
|
|
|
|
You are explicitly calling the destructor. This will free the allocated memory for the members but not the object itself. You should use delete instead:
delete allo;
Or you may use auto delete (using an additional member var):
Process::~Process()
{
delete m_proc;
if(m_filename) delete [] m_filename;
if (m_bAutoDelete)
delete this;
}
|
|
|
|
|
that pretty much solved me the problem
something to note
delete still calls the destructor.
so the auto delete code that you provided will cause an exception.
Process::~Process()
{
if(m_bDeallocated)
return;
delete m_proc;
delete [] m_filename;
m_bDeallocated = true;
if (m_bAutoDelete)
delete this;
}
|
|
|
|
|
Yes, you are right. That would result in a recursion. My code lacks resetting the m_bAutoDelete variable. It must be:
Process::~Process()
{
if (m_bAutoDelete)
{
m_bAutoDelete = false;
delete this;
}
else
{
delete m_proc;
delete [] m_filename;
m_proc = NULL;
m_filename = NULL;
}
}
However, this is not a good solution because the destructor is called twice and this will fail if the object wasn't allocated using new .
|
|
|
|
|
thank you and the reply, I learned something for this question. thanks again!
|
|
|
|
|
I'm trying to read the context of a PDF file(such as reading the word following the cursor) and
I used class wizard to add some header files (add class form Typelib ---> acrobat Access 3.0 Type Library<3.0>) to my project and include these header files in one .cpp file, but when compile, many compile error occurs.
what I know is as follow:
each header file imported include such line : "
#import "C:\\Program Files\\Adobe\\Acrobat 10.0\\Acrobat\\plug_ins\\Accessibility.api" no_namespace
"
when I comment out this line and then compile, everything is OK, but I'm not sure is it OK to do so, by the way I'm searching what the *.api file and its function on google and baidu(another search engine)
anyone who had read PDF file may help,
I really appreciate your help. thanks.
|
|
|
|
|
Did you check the documentation[^]?
Also, if you want help then you need to explain exactly what error(s) you see, we cannot guess what happens.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
thanks for your reply, I have read the document, but I am not sure how to access PDF files.
the error is as follow:
error C2011: 'IAccessible' : 'struct' type redefinition
...
many this kind of error.
the headers imported is a wrap of I* interface,for example
CAccessible == IAccessible.
CAccID == IAccID
|
|
|
|
|
It looks like you have duplicate definitions in one or more of your source files. Check which headers you are including.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
I know this, but I really didn't include more than one header. I am quite puzzled. thanks all the same.
|
|
|
|
|
I have recently spent some time getting some of my apps looking right on XP styles, by adding a manifest resource, and also modifying some controls that are custom-drawn.
However, if I use my xp-style-enabled controls in apps which do not have a manifest, and therefore draw using the old style, I find that my controls still draw with the current XP style. I have used IsAppThemed() as a way of determining how to draw my controls, but I have found that this returns TRUE even though the app is not XP-style-enabled, making the control look odd! I have tried using IsThemeActive but this also always returns TRUE.
Does anyone know how I can find out if the app is XP-styled (ie the other controls are using the XP-styles)?
|
|
|
|
|
See this MSDN blog post[^].
I'm not really sure if this is of much help for you. But you may find some clues in the comments.
|
|
|
|
|
Thank you. I found an answer
|
|
|
|
|
1 )
int a;
a = 5;
2 )
int a(5);
3 )
int a = 5;
Prafulla Vedante
|
|
|
|
|
In case 1 you have declared the variable a but it has no value; in reality it will but its contents will be random. The second statement assigns the value 5 to variable a . These two statements do not need to be together, as a can have its value set or reset anywhere it is in scope.
Cases 2 and 3 are the same, the variable is declared and initialised at the same time.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
1. Declaration (after which the variable will be uninitialised, with an unknown value) followed by assignment.
2. Declaration with initialisation. For POD (Plain Old Data, built-in) types, this is effectively no different to 3. but with a class/struct type this would call a different constructor (taking an int parameter, rather than the default constructor).
3. Declaration followed by assignment. Again, for a POD type no different from 2. but with a class/struct type the value 5 could be implicitly converted to the class/struct type in a custom constructor before the assignment, or an assignment operator taking an int could be called.
In questions of declaration, initialisation, assignment and so on, what POD types do is well known and specified in the standard, but what class/struct types do depend on their implementation to a much larger extent.
|
|
|
|
|
Not quite correct. Cases 2 and 3 are equivalent - the assignment operator is, in fact, not used in case 3, not even for a custom class with an override for operator=() .
See GotW#1 for further explanations. I have to admit I wouldn't have known the (lack of) difference before checking that site.
|
|
|
|
|
|
Hello all,
I'm new to C and i received a challenge to work on a project to integrate 2 different machines. One of the machines is a scanner. A protocol was developed to make the conversation" between the 2 machines possible using the serial over USB physical link.
I have the specification of this protocol with the commands that the scanner can receive and what is the expected response. All commands work perfectly however i'm in doubt on how to retrieve the image from the scanner.
See the command definition below:
Request syntax :
000200000000crc16
The scanner response in case of success will be :
[“0002”][length][image data in binary][crc16]
As The payload field in this response will be a BINARY stream of octets that needs no further conversion prior to be saved in a file or to be delivered to its final destination.
To better ilustrate the response is something like:
000200006690bin_datacrc
Where:
0002 is the command
00006690 is the lenght of the img data
bin_data is bin image data
crc
The problem is that i don't know how to handle BINARY stream of octets. I read a couple of articles but they are always related to read bin data from files and in this case we have a stream and i'm not sure if it's the same.
Do you know a possible solution to write this BINARY stream of octets in a file ???
If someone can share some info i really appreciate it!!!
Thanks and congrats for the great job you guys do here at the forums...
Simplicity is the Ultimate Sophistication!!!
|
|
|
|
|
Just use the BYTE (or unsigned char ) type to read and write. I don't know what I/O functions you are using, but you could use the CRT Stream IO functions[^]. Thus to read and write you would do something like:
FILE* fin = fopen("inputfilename", "rb");
FILE* fout = fopen("outputfilename", "wb");
DWORD count = ??; BYTE buffer[999]; int nread, nwritten;
do
{
nread = fread(buffer, sizeof(BYTE), count, fin);
if (nread < 1)
break; if (nwritten < fwrite(buffer, sizeof(BYTE), count, fout))
{
}
} while (nread > 0);
Obviously this needs expanding but it should give you the idea.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
Marcio Kugler Rodrigues wrote: Do you know a possible solution to write this BINARY stream of octets in a file ???
It is just a bunch of bytes. If you have the pointer to the first of them (that is the address of the start location wherein you have read them), say buffer , then you have just to issue (assuming you are working on Windows OS ):
FILE * fp = fopen("my_image.tiff", "wb");
if ( fp )
{
if ( length != fwrite(buffer, 1, length, fp) )
{
}
fclose(fp);
}
else
{
}
Veni, vidi, vici.
|
|
|
|
|
Hello everybody,
How can I enabled a service to interact with desktop in 2008 Windows server OS ?
I have a MFC application which is run by being called by another service which its properties are localsystem and interact with desktop.
It works fine at 2003 Windows server OS, but I face problems with 2008 Windows OS (NO GUI enable though I see it as a running process)
Any clue how to let it enables the GUI ?
I searched the internet and forums for any idea but with not much help.
Please advice.
Thanks in advance,
Eyal
|
|
|
|
|
es1968 wrote: how to let it enables the GUI ? It doesn't. Services run in the background and are prevented from having a Windows front end, specifically because they do not have user interaction. You can provide an interface so a normal GUI based program can pass information to and from the service, but that's all that is allowed.
One of these days I'm going to think of a really clever signature.
|
|
|
|
|
I have an layered window over a CMyView derived from CScrollView. This layered window are created, but are not painting, I mean CLayered::OnPaint are not calling (ON_WM_PAINT is properly mapped)... there is any reason to CWnd::OnPaint not being executed ? Thank you.
|
|
|
|
|
Flaviu2 wrote: is any reason to CWnd::OnPaint not being executed If this was true then nothing would work. You need to look again at your program to ensure that all events are correctly wired up.
One of these days I'm going to think of a really clever signature.
|
|
|
|