|
|
great!
QueryPerformanceCounter() works perfect!
It is really impossible if you are not good enough.
|
|
|
|
|
Hello!
I use Visual Studio 2005 SP 1. Here it a part of my code:
CStdioFile fd;
CString t;
fd.Open(_T("rep.txt"), CFile::modeRead, 0);
fd.ReadString(t);
This file contains the russian language and when I use debugger I see that 't' contains is 'm_pszData 0x003BBA60 "CSAD|Air Tube (òðóáêà äëÿ îòâîäà òåïëà îò ïðîöåññîðà)|2" wchar_t*'
You see, that russian part is unreadable. My project has Unicode libraries support and I can use Russian in my project, but 'Read string' has the problem. Can you help me?
|
|
|
|
|
yaros21 wrote: ...when I use debugger I see that 't' contains is 'm_pszData 0x003BBA60...
Are you viewing it with the "su" debugger symbol?
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thanks you, but I've already solve it. In project properties I switched 'Character set' to 'Use multi-Byte character set' and it works well now. Unicode isn't crucial for my project.
|
|
|
|
|
i am using the .NET.
i need to fetch the attributes from the wmv/wma file.
e.g. time(created,access,modified)bitrate,size,duration,extension(avi/mpeg/wmv).
i have used the above API function FileTimeToSystemTime(&ft,st)
ft is FILETIME.
where st is LPSYSTEMTIME.
When i debug it gives memory error.
all these attributes i need to display in the listview like search which gives us
all files list information with attributes.
Thanks in advance
amit mistry
|
|
|
|
|
LPSYSTEMTIME st
is the same as
SYSTEMTIME*st;
you must do in this way:
SYSTEMTIME st;
FileTimeToSystemTime(&ft,&st)
|
|
|
|
|
Hi,
I tried to raise an event from unmanaged code class to a class in managed code.
I passed a delegate pointer (using Marshal) to the unmanaged class but I got an error when the unmanaged class tried to execute the function.
I tried to use pin_ptr to the delegate pointer with no results.
How can I raise event from unmanaged code class to a managed code class using delegate (managed) and function pointer(unmanaged)?
Thanks
|
|
|
|
|
I don't think that it is possible to raise event directly from unmanaged code, but it is possible to call managed callback function which does this. Use Marshal.GetFunctionPointerForDelegate method to pass managed callbak function address to unmanaged code.
Keep delegate instance alive all time when callback function can be called.
|
|
|
|
|
Thanks for your reply,
I've a delegate instance that lives all the time and I sent it to the unmanaged code using Marshal.GetFunctionPointerForDelegate.
But I think there is a problem with the GC since it can be reallocated the delegate on the heap.
How can it be handle?
Thanks
|
|
|
|
|
I think that that delegate is pinned internally by this function. .NET doesn't allow to take unmanaged pointers to managed unpinned objects.
You can do this manually using GCHandle, as shown in MSDN topic "GCHandle.Alloc Method (Object)", but I think this is exactly what GetFunctionPointerForDelegate does.
|
|
|
|
|
How to find the pointer is initialized or not.
In destructor, if I delete the pointer array like:
if(ptr)
{
delete [] ptr;
}
an exception is got inside catch(...){}.
The if condition is sucess even if the pointer is not initialized.
The pointer address is 0xcccccccc.
Thanks & Regards,
Suman
|
|
|
|
|
if(ptr)
{
delete [] ptr;
}
is totally bad C++ code.
just do:
delete [] ptr;
because if ptr==NULL, you delete it without any problem.
for code like above, you must init at begining like:
ptr=0;
if the ptr will be reused, you must init after delete like:
delete []ptr;
ptr=0;
|
|
|
|
|
Always init your pointers to NULL (0xcccccccc is what the debugger sets uninitialized memory/variables to).
If a pointer's value is NULL, then it's not pointing to anything.
If the value is anything else, it might point to valid memory, or it might not. There is no foolproof way to tell.
|
|
|
|
|
Thanks for help!
In release mode there is no error caught by catch() when deleting unintialized pointer.
I think there is no fixed value for unintialized pointer in release mode.
Is there any chance of deleting the memory of other variable or function when deleting the unintialized pointer?
Is it possible to know the address is some other variable / function's memory.
Thanks & Regards,
Suman
|
|
|
|
|
It's your responsibility to make sure any pointer that you dereference is pointing to valid memory. That's why C++ guys make the big bucks
|
|
|
|
|
Thank you very much for your great help!
Wishing you a Very Happy and Prosperous New Year 2007!!
Thanks & Regards,
Suman
|
|
|
|
|
IsBadReadPtr & IsBadWritePtr may help you by indicating if the pointer is readable and/or deletable.
Possibly also HeapWalk could help.
|
|
|
|
|
IsBadReadPtr() and IsBadWritePtr() don't work and can actually cause more problems. See this blog[^] for more
|
|
|
|
|
Sorry about that. I didn't know the internal mechanics of these two APIs, nor that their usage can lead to such disasters.
Then I suppose remains HeapWalk... or also this one contains a hidden treasure as well?
|
|
|
|
|
Thanks a lot for the great help from you all!!
Thanks & Regards,
Suman
|
|
|
|
|
now i want to get some informations about the local Floppy Driver. the information may content Vendor ID, Product ID ... or some thing else~
can anybody give me some hint?
if C/C++ can do this tell me how, if not give me some explaination.
thanks ~~~
|
|
|
|
|
CreateFile to open the floppy device;
DeviceIoControl with codes of choice; may include:
- IOCTL_STORAGE_GET_MEDIA_SERIAL_NUMBER
- IOCTL_STORAGE_GET_MEDIA_TYPES(EX)
etc.
|
|
|
|
|
i got the answer in the Hardware board...
For a floppy drive? There isn't a way to do this. The Device Manager in Windows doesn't care. As far as I know, most of them come back as a Generic Drive on a Standard Controller. About the only ones that would come back with any information are the old 120MB Super Drives.
Dave Kreskowiak
Microsoft MVP - Visual Basic
-- modified at 20:19 Tuesday 26th December, 2006
|
|
|
|
|
Dear All,
Dear Mr.Asef (Iran)
I need to control a peripheral device via parallel port (LPT) by programming Visual C++ language but I'm still confused how to do it.
I have down loaded the program written by Mr. Asef (Port Access
By asef.)but it doesn't work properly , I think that may be I have miss something...
Would you please help me and give me your instruction to solve this problem!
my email: bangkokhanoi2007@yahoo.com
Thank you in advance!
Your sincelery,
BK2007
|
|
|
|