|
My main question is, I need to be able to get the filesize of a file greater than 4 gb. I use Visual C++ 6.0, and I am most comfortable with fstream. The fstream pointers are only 32 bit however. Is there another function I can use to get the filesize?
Two secondary questions are, one problem I have is sometimes the autocomplete/member listing stops working. I have to save everything, close, and reopen VC++ to get them to work again. Is there another way to fix it? And sometimes during compiling it will just stop before linking. I'll press the stop build button and it won't stop, I have to save everything and end the process via Task Manager. Is there a better way to fix that?
Thanks in advance for any help.
|
|
|
|
|
Master Shake 144 wrote:
Is there another function I can use to get the filesize?
I know of two: GetFileSizeEx() and CFile::SeekToEnd() (requires opening the file).
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
GetFileSizeEx only works on W2K+.
CFile::SeekToEnd() returns a 32bit value in MFC 6, a 64 bit value in MFC 7
_lseeki64 works on 9x and MFC6
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it! Honoured as one of The Most Helpful Members of 2004
|
|
|
|
|
|
|
int main(int argc, char* argv[])
{
switch(argc)
{
case 1:
break;
case 2:
if(argv[1] == "-help")
{
cout << "Help" << endl;
}
break;
default:
break;
}
return 0;
}
If the program in this case is named "prog.exe", when I type "prog.exe -help" into the command line, my understanding is that "Help" should be printed into the command line window. Any ideas as to why it isn't working?
Also, if there is a better way to check to see which program parameters have been passed in than the way I am trying to do so, please let me know. I am open to suggestions.
John 3:16: "For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life."
|
|
|
|
|
One solution is strcmp().
Kuphryn
|
|
|
|
|
Thanks for the help!
John 3:16: "For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life."
|
|
|
|
|
bneacetp wrote:
if(argv[1] == "-help")
Herein lies your problem.
|
|
|
|
|
Yep. I agree. I changed
if(argv[1] == "-help") to
if(strcmp(argv[1], "-help") == 0) and that solved the problem.
Thanks for taking the time to point that out.
John 3:16: "For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life."
|
|
|
|
|
Unless you REALLY need to look exactly for "-help" I would recommend a case insensitive string comparison. Not all users rememebr you want all lower case for command line arguments, for example - see stricmp
|
|
|
|
|
Alright. That certainly is a good suggestion. Thanks.
I believe I will make that change. Thanks for taking the time to let me know about the stricmp() function.
John 3:16: "For God so loved the world, that he gave his only begotten Son, that whosoever believeth in him should not perish, but have everlasting life."
|
|
|
|
|
how do i create a PE explorer or a resource hacker?
|
|
|
|
|
There is a very small-scale one on MSDN, and a much better one here at CP. Have you tried Googling?
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
Hi everyone!
I'm trying to send VK_RCONTROL to an application by unsing the SendInput method.
Does anyone know how to do this?
void sendChar(BYTE c){
INPUT input[2] = {0};
input[0].type = input[1].type = INPUT_KEYBOARD;
input[0].ki.wVk = input[1].ki.wVk = c;
input[1].ki.dwFlags = KEYEVENTF_KEYUP;
::SendInput(sizeof(input) / sizeof(INPUT), input, sizeof(INPUT));
}
//Doesn't work
sendChar(VK_RCONTROL);
|
|
|
|
|
Can you try it with the VK_CONTROL to see if it works?
I found this comment in WINUSER.H, which makes me suspicious that the VK_RCONTROL might not work ever.
* VK_L* & VK_R* - left and right Alt, Ctrl and Shift virtual keys.
* Used only as parameters to GetAsyncKeyState() and GetKeyState().
* No other API or message will distinguish left and right keys in this way.
|
|
|
|
|
Thanks for the response!
I've tried VK_CONTROL, but it will act as the left control button.
Since the program I'm trying to send right control to is making a destinction between right and left, there has to be a way to send right control. (read hack)
/Peter
|
|
|
|
|
This is what I got to work:
sendChar(VK_RCONTROL, 0x1D, TRUE);<br />
<br />
void sendChar(BYTE c, WORD wScanCode, BOOL bExtended)<br />
{<br />
<br />
INPUT input[2] = {0};<br />
<br />
input[0].type = INPUT_KEYBOARD;<br />
input[0].ki.wVk = c;<br />
input[0].ki.wScan = wScanCode;<br />
if( bExtended ){<br />
input[0].ki.dwFlags = KEYEVENTF_EXTENDEDKEY;<br />
}<br />
<br />
input[1].type = INPUT_KEYBOARD;<br />
input[1].ki.wVk = c;<br />
input[1].ki.wScan = wScanCode;<br />
input[1].ki.dwFlags = KEYEVENTF_KEYUP;<br />
if( bExtended ){<br />
input[1].ki.dwFlags |= KEYEVENTF_EXTENDEDKEY;<br />
}<br />
<br />
UINT uCount = ::SendInput(sizeof(input) / sizeof(INPUT), input, sizeof(INPUT));<br />
<br />
}
Whether or not the scan code was sent, and with the virtual key always set to VK_RCONTROL, the 'virtual key' my test progrma always received in the WM_KEYDOWN and WM_KEYUP was always VK_CONTROL.
I tried leaving out the scan code (or setting it to zero) and without the 'proper' scan code, the key events the progrma receives look like a regular CONTROL key with the 'extended key' flag bit set. I am not sure that your program processing the input would interpret that as the 'right' control key, but you can test it. You might need to add the scan code, but be aware that the scan codes can vary by keyboard. As a result, you might need to provide a 'configuration utility' to allow user to enter the scan codes for the special 'extended' keys you want to send.
|
|
|
|
|
Cool!
It works flawlessly, I didn't even have to change the scan code!
Thank you very much!
/Peter
|
|
|
|
|
here is how I understand the job of this function :
Let's say I have an EditBox (which ID is IDC_MYEDIT),a pointer to that CEdit (called m_pMyEdit) and a CString object (called m_strEditText) associated to the control by DDX (DDX_Text (pDX, IDC_MYEDIT, m_strEditText); ).
When I call UpdateData(TRUE) , IDC_MYEDIT is filled with the content of m_strEditText.
When I call UpdateData(FALSE) , m_strEditText is affected with the content of IDC_MYEDIT.
until there, am I still right ?
Now, here is my problem:
<font color=#0000FF>void</font> CMyClass::OnEditMyEdit() {
UpdateData(); <font color=#008000>
<font color=#0000FF>int</font> iStartSel = m_strEditText.GetLength();
<font color=#008000>
m_strEditText = <font color=#008000></font>;
UpdateData(FALSE);
m_pMyEdit->SetSel(iStartSel, -1);
} This code is supposed to search for the string typed in the EditBox into a ComboBox, complete the string, then select its content that was added programatically (I try here - maybe you understood it - to make an auto-complete with a case sensitive behavior).
The problem is that, if I use UpdateData(FALSE), the completion is not what I expect.
However, if replace
UpdateData(FALSE); with
m_pMyEdit->SetWindowText(m_strEditText); , my function works exactly as I want of it...
Did I misunderstood how UpdateData() worked ?
Did anybody encountered such a problem, or a problem with This function ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
See here.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
toxcct wrote:
When I call UpdateData(TRUE), IDC_MYEDIT is filled with the content of m_strEditText.
When I call UpdateData(FALSE), m_strEditText is affected with the content of IDC_MYEDIT.
No, that's backwards. Passing TRUE copies from the control to the variable. Your sample code is using the paramter correctly, however.
The first thing to check is that you call UpdateData(FALSE) in OnInitDialog() . You need to call that once before all other DDX operations. The wizard-generated code does this, so check that you didn't accidentally delete it.
--Mike--
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
Michael Dunn wrote:
so check that you didn't accidentally delete it.
First, i didn't delete anything from OnInitDialog() (and it is not the first time i program a dialog box), and moreover, the call of UpdateData() is made into CDialog::OnInitDialog() , not into mine...
secondly, my other handlers work well, and i just have this one that behaves strangely...
i really don't understand why, but i "very sure" that the problem comes from the call of that function...
... And as i don't want to mix the uses of UpdateDate() and SetWindowText()...
any tips ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Hey,
I have a class (derived from CObject) containing variables (and functions). I put this class (Object) into a CObArray. Now I would create a copy of the class as a NEW Object (thus not only a copy of the pointer as with CObArray.copy).
Do I have to copy all Member of the class "by hand" or is there a more comfortable way.
Thanks in advance...
|
|
|
|
|
depends...
the objects, you copy them "by hand".
the pointers, you should allocate a new memory area to copy its content (otherwise, if you just copy the pointer, you will have 2 pointers - with so the same address inside - pointing to the same object). this will avoid modifying the same object when you think they have each theirs, and delete ing 2 times the same object.
That is for your own class members. For the base class (here, CObject), call its constructor before the instructions block (sorry, I lost the name of this place ) :
CMyClass::CMyClass(CMyClass& ref) : CObject() {
}
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|