|
When i select from the menu the the file -> open
then were is the handle to the file
I want to access the data of the file , say i open
a text file and then want to store the data back
to the file .
IS there any clean article for it
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
You don't need a file handle. use the document class's Serialize method instead
the CArchive parameter points to the file being opened (File -> Open) or saved (File -> Save)
void CTestAppDoc::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{
}
else
{
}
}
look up Serialize[^] and CArchive[^] in MSDN for further details
|
|
|
|
|
Subject : An object(file or folder) which can mask only from copy and Paste..
is it possible to mask the properties "Copy" and "Paste"( both by mouse and key board)for a paticular file or folder.ie while right clicking on the file the "copy" and "paste" in the context menu should be inactive.
If any reply on this plz send it to harias25@sify.com
Hareesh A S
Software Developer,
Singapore.
|
|
|
|
|
I have an OCX Control, created with Visual C++ 6.0
I created another new OCX control, modifying the first one with very little changes. I renamed and registered the new one but it replaced the old one.
My problem is that I want both. Renaming the OCX and registering did not help me. How do i do this? Any help is greatly appreciated.
I am sorry if this is a wrong place to have posted this question.
Regards,
Rajesh R. Subramanian
You have an apple and me too. We exchange those and We have an apple each.
You have an idea and me too. We exchange those and We have two ideas each.
|
|
|
|
|
It's not enough to rename it, you have to change it's CLSID too. Use uuidgen.exe tool to generate a new one and then register it again.
|
|
|
|
|
Heartfelt thanks for your reply.
Regards,
Rajesh R. Subramanian
You have an apple and me too. We exchange those and We have an apple each.
You have an idea and me too. We exchange those and We have two ideas each.
|
|
|
|
|
Hello everone
I have a file in which the data is stored in hex format,
i need to convert some bytes to DWORD ,exactly 4 bytes
to a DWORD .
i created such a complex statement for that
DWORD biWidth=(unsigned char)m_FileData[18] +((unsigned char)m_FileData[19]*256) +((unsignedchar)m_FileData[20]*65536) +((unsignedchar)m_FileData[21]*16777216);
But i think this is not an effecient way because a heavy arithmatic is used.
is there any other method that is fast an effecient .
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
Hello,
This is a heavy statement indeed and it can be done much simpler indeed:
DWORD biWidth = *reinterpret_cast<DWORD*>(&m_FileData[18]);
This is the way to go and requires minimal CPU time.
Hope this helps.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
-- modified at 2:45 Wednesday 21st December, 2005
|
|
|
|
|
That great i was looking such
a thing which would be fast &
more effecient.
tank you again
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
You're welcome.
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
BoB i am sorry but ur method
creates error
m_BITMAPFILEHEADER.bfSize = *reinterpret_cast<DWORD*>(&m_FileData[18]);
It worked fine for some file but not with other
, we need to find some other solution
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
Hello,
What kind of error are you getting? Is m_FileData a BITMAPFILEHEADER ? If you, you can use a href="http://msdn2.microsoft.com/en-us/library/wes2t00f.aspx" rel="nofollow">memcpy_s()</a>[<a target=_blank title='New Window' rel='nofollow' href="http://msdn2.microsoft.com/en-us/library/wes2t00f.aspx">^</a>] to copy all contents!
Behind every great black man...
... is the police. - Conspiracy brother
Blog[^]
|
|
|
|
|
The question is how your statement is handeled by the optimizer.
It's not unlikely that it will use shifts instead of your numbers. Using shifts would probably make the code more effecient.
It's not always true that a simple statement (to write) gives the smallest and most effecient code in the exe file...
Kakan
|
|
|
|
|
Kakan -->
The question is how your statement is handeled by the optimizer.
It's not unlikely that it will use shifts instead of your numbers. Using shifts would probably make the code more effecient.
It's not always true that a simple statement (to write) gives the smallest and most effecient code in the exe file...
Kakan
vikas -->
Yeh probaly it is true that a simple statement might be not always effecient
but
Its always simple to read & understand , which infact saves lots of time for understanging.
(Code read more times then it is written )
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
Yes. But the program is executed a lot more times than the code is read...
|
|
|
|
|
any way (no one is wright or wrong it the time who governs his statement)
the method supported by Bob
dont work fine for ever file i think
we need to think back how to solve the
problem .
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
You can try this, if m_FileData is an unsigned char[]:
DWORD biWidth = m_FileData[18] | (m_FileData[19] << 8) | (m_FileData[20] << 16) | (m_FileData[21] << 24);
Kakan
|
|
|
|
|
Hi everybody
I am developing an internet explorer toolband, with many functions, one of them a popup blocker button. I was searching in the examples, but all the examples have ATL or MFC functions, and i need do all that things without using any ATL or MFC functions.
If anybody can helpme i will be gratefull
|
|
|
|
|
Without using MFC and ATL
u will need to lots of stuff by ur self.
Must rewrite all the MFC function used in
ur program .
And if u mean to create a pop-up blocker
might be u need to use window messages
so win32 can come to ur resuce.
DLL's can help u but i cant say it for sure
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
neliocc wrote: . I was searching in the examples, but all the examples have ATL or MFC functions,
Buddy, it would be easier if you use ATL to develop toolband application for IE, as IE provide automation support for same.
but if you still insist on using pure Win32 Api, here is hint...
you have to create the dll, which contain the Window Which subclass main window for Window Message... also another application which inject this dll into process space of IE ( for that you have to create system wide hooks). not the easy task, but i believe thats the only way to get there.
you have to Hook the system for IE instance...
"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
|
|
|
|
|
I think you should look into creating a Browser Helper Object (BHO).
|
|
|
|
|
I'm stepping through my disassembled code:
<br />
*buffer2 = *buffer1; QUESTION 1<br />
<br />
00411AED cmp byte ptr [ebp-119h],0 QUESTION 2<br />
00411AF4 jne main+0D3h (411B03h) <br />
00411AF6 push 411B6Bh <br />
00411AFB call @ILT+555(__RTC_UninitUse) (411230h) <br />
00411B00 add esp,4 <br />
00411B03 cmp byte ptr [ebp-10Dh],0 <br />
00411B0A jne main+0E9h (411B19h) <br />
00411B0C push 411B63h <br />
00411B11 call @ILT+555(__RTC_UninitUse) (411230h) <br />
00411B16 add esp,4 <br />
00411B19 mov eax,dword ptr [buffer2] <br />
00411B1C mov ecx,dword ptr [buffer1] <br />
00411B1F mov dl,byte ptr [ecx] <br />
00411B21 mov byte ptr [eax],dl <br />
QUESTION 1
*buffer2 = *buffer1;
How's this one line translated to this this big chuck of disassembly? (I'm assembly newbie, playing with WinDbg, going thru instruction sets and trying to see things in action)
And, the first line of disassembly is a CMP instruction??
QUESTION 2
00411AED cmp byte ptr [ebp-119h],0 QUESTION 2
okay, is "ptr" a keyword? References? Also, is "byte" a keyword?
I'm looking at WinDbg's manual, the reference is... less than ... For example:
MOV r1, r/m Move with zero extension.
It doesn't state if parameter 1 is source or destination! Any good reference source?
QUESTION 3
How come "main" does not start with address 00000000? #include "stdafx.h" #include <stdio.h> int _tmain(int argc, _TCHAR* argv[]) { 00411A30 push ebp 00411A31 mov ebp,esp 00411A33 sub esp,120h
When I run WinDbg,
ModLoad: 00400000 0042c000 C:\development\Samples\TestDebugger.02\Debug\TestDebugger.02.exe
ModLoad: 77f50000 77ff7000 C:\WINDOWS\System32\ntdll.dll
ModLoad: 77e60000 77f46000 C:\WINDOWS\system32\kernel32.dll
Where's 00000000 to 00400000? What's in it?
QUESTION 4
Where's the "stack", is there a memory address...? Is EBP register the "address" of stack location in process memory/address space? And ESP (stack pointer) pointing to top of stack - but is it just a relative/offset from EBP? I assume EBP is "absolute" address based 00000000 (ie. start of process address space), am I right or wrong?
QUESTION 5
These addresses I see on stack trace, for example, 00411AED, is it "Virtual"? Where's the "zero" point?
Thanks in advance.
Norman Fung
|
|
|
|
|
So much of code is added to check for runtime errors:
First of all, checks are performed...
00411AED cmp byte ptr [ebp-119h],0 (check if buffer1 has been initialized or not)
00411AF4 jne main+0D3h (411B03h) ( if initialized, check for next value)
00411AF6 push 411B6Bh ( else push some sort of argument for function __RTC_UninitUse on the stack )
00411AFB call @ILT+555(__RTC_UninitUse) (411230h) ( call the error handler )
00411B00 add esp,4 ( pop value from the stack )
00411B03 cmp byte ptr [ebp-10Dh],0 ( check buffer2 )
00411B0A jne main+0E9h (411B19h) (...)
00411B0C push 411B63h (...)
00411B11 call @ILT+555(__RTC_UninitUse) (411230h) (...)
00411B16 add esp,4 (...)
Actual work starts here:
00411B19 mov eax,dword ptr [buffer2] (store the buffer2 pointer in eax)
00411B1C mov ecx,dword ptr [buffer1] (...)
00411B1F mov dl,byte ptr [ecx] (copy a byte to dl from address pointed to by ecx)
00411B21 mov byte ptr [eax],dl ( copy a byte from dl to the address pointed to by eax )
done
"Do first things first, and second things not at all."
— Peter Drucker.
|
|
|
|
|
Hey thanks that's very helpful, but where's the stack in memory. I used WinDbg to lookup memory allocated for loaded "exe", as well as that for system services "ntdll" and "kernel32":
ModLoad: 00400000 0042c000 C:\development\Samples\TestDebugger.02\Debug\TestDebugger.02.exe
ModLoad: 77f50000 77ff7000 C:\WINDOWS\System32\ntdll.dll
ModLoad: 77e60000 77f46000 C:\WINDOWS\system32\kernel32.dll
But where's the stack? Each process gets its own address space. Is stack allocated in 00000000 to 00400000 (Before the "exe" address block)? How big can a stack gets?
Norman Fung
|
|
|
|
|
Hey thanks, that's very good ... I got another question:
00411B19 mov eax,dword ptr [buffer2] (store the buffer2 pointer in eax)
00411B1C mov ecx,dword ptr [buffer1] (...)
Why not write this:
00411B19 mov eax,dword ptr [buffer2] (store the buffer2 pointer in eax)
As:
00411B19 mov eax, ebp + 0xsomeoffset
Perhaps it's because the buffer is on the "heap" and not on "stack"? But how does the CPU knows of the symbolic token [buffer1] ...? I thought everything is memory buffer with address in assembly level.
And why "dword" and "ptr" in the instruction? I understand "dword" = 32 bits (well, I guess this is why because it specify buffer size so "mov" command can move buffer of right size... am I right?) and "ptr" = pointer... but why... do we need this in the argument?
Norman Fung
-- modified at 22:38 Wednesday 21st December, 2005
|
|
|
|