|
JoeSchmoe007 wrote: Does anyone have any ideas on how this is achieved using Windows API?
How about shutting down your application?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
File is still locked after application is shut down. I edited original post to reflect that. For what it's worth - our application is a service.
|
|
|
|
|
JoeSchmoe007 wrote: File is still locked after application is shut down.
Then some other process is using it, or your application is still running.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
You can use Process Explorer (run it without installation wrom live sysinternals site[^]) to find out which process is holding your file.
|
|
|
|
|
There is a way to forcibly close handles - because Process Explorer can do it.
However, in this situation, you should use MoveFileEx[^] with the MOVEFILE_DELAY_UNTIL_REBOOT flag and a NULL destination filename and Windows will perform the file deletion at the next boot time, before any applications have started to lock the file.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Just close the handle remotely (classic and official method, Win32 (news://comp.os.ms-windows.programmer.win32) since 90's..)
|
|
|
|
|
Hmm guys,is it possible to display number1+ number2+number3?
Eg,if a program prompts a user to input 3 numbers,N1,N2 and N3,is it possible for the program to display N1+N2+N3?As far as i know,we can use a while loop to straight away give us the final answer for N1+N2+N3.
To make it clear,if i input 5 as N1,10 as N2 and 15 as N3,can we make the program display
"total=5+10+15=30" instead of "total=30"?
Can someone guide me on this. xD
|
|
|
|
|
UKM_Student wrote: As far as i know,we can use a while loop to straight away give us the final answer for N1+N2+N3.
That would be the wrong thing to use.
UKM_Student wrote: To make it clear,if i input 5 as N1,10 as N2 and 15 as N3,can we make the program display
"total=5+10+15=30" instead of "total=30"?
See here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Erm yeah that was a response to my earlier question,what about this one
This question is asking whether can we display the value(s) we take and then adding them up instead of getting a final answer right away o-o
|
|
|
|
|
UKM_Student wrote: Erm yeah that was a response to my earlier question,what about this one
The same response applies. You can have multiple values for a single cout statement.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Erm im not trying to display exactly the numbers lol.Go see the program i wrote in the other page xD
|
|
|
|
|
why is it wrong?For eg.
#include<iostream>
using namespace std;
int main()
{
int total=0,count=0,number;
while(count<5)
{
cout<<"Input 5 numbers.";
cin>>number;
total=total+number;
count++;
}
cout<<"Total is "<<total<<endl;
return 0;
}
From here we can see that the compiler adds up all the 5 numbers.My question is how should i put it so it would display" total: N1+N2+N3+N4+N5=XX "instead of adding all the numbers up then display "total:XX"
|
|
|
|
|
UKM_Student wrote: why is it wrong?
Because you wanted to use a while() loop to sum N1 , N2 , and N3 . Given:
int N1, N2, N3;
while ()
{
} How would that work?
UKM_Student wrote: cout<<"Input 5 numbers.";
This should probably go outside the while() loop.
UKM_Student wrote: My question is how should i put it so it would display" total: N1+N2+N3+N4+N5=XX "instead of adding all the numbers up then display "total:XX"
Given that you are not saving number each time through the loop, you can't.
Consider:
int count = 0, number[5];
while (count < 5)
{
cin >> number[count];
total += number[count];
count++;
}
cout << endl << "total: ";
count = 0;
while (count < 5)
{
cout << number[count];
if (count < 4)
cout << '+';
}
cout << '=' << total;
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Erm i tried running ur program but it was an infinite loop o.o
and whats the meaning of number[5]?I don't think that part is yet of my lvl(i just started C++ for less than 2 months :P)
|
|
|
|
|
See my last answer to your previous question. You really need to study the C language further in order to understand some of the answers given here. Most of the people providing answers here are assuming that you have a basic knowledge of all C language constructs; your supplementary questions make it clear that you have not.
This is not a criticism of you (we all had to start somewhere), rather advice on how to get to the place you want to be.
|
|
|
|
|
Well,i just started learning it in less than 2 months,ie about 8 hours of C++ programming only and the lecturer already gave us such homework,so...
|
|
|
|
|
UKM_Student wrote: so...
So if he's any good at his job he has taught you all you need to know to solve the problem you have been given. Maybe you need to read through your notes again, to refresh your memory of the bits you have been studying. As my mentor 'Big John' was fond of repeating ad nauseam: "practice, practice, practice".
|
|
|
|
|
yeah and that's what i i'm doing
|
|
|
|
|
UKM_Student wrote: Erm i tried running ur program but it was an infinite loop o.o
Did you remember to increment count ?
UKM_Student wrote: and whats the meaning of number[5]?
It's an array of 5 integers.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
i declared the variable "total" and where do i do the increment count thingy?Sorry i kinda noob
Array of 5 integers meaning?
|
|
|
|
|
UKM_Student wrote: ...where do i do the increment count thingy?
In the while() loop.
UKM_Student wrote: Array of 5 integers meaning?
Instead of having:
int number1, number2, number3, number4, number5; it would be easier to have:
int number[5]; Wouldn't you agree?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
kinda but my lecturer haven't taught me that yet so i don't it would be decent for me to use that xD
Oh btw,can help me one last time?
MY last question(Thank God) is to display all upper case letters using a while loop.Any idea how to do it? xD
If im not mistaken,i think we nid to use char type
|
|
|
|
|
UKM_Student wrote: ...but my lecturer haven't taught me that yet so i don't it would be decent for me to use that
Agreed. In that case, you'd need 5 separate variables.
UKM_Student wrote: MY last question(Thank God) is to display all upper case letters using a while loop.Any idea how to do it?
Yes, I have an idea. What are you proposing and I'll nudge you along?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Lol ok xD
cout<<"f. The display of Upper Case Letters are as follows : ";
char Letter1,counter=1,Letter,a;
while((counter<=26))
{
Letter1=a;
Letter=Letter1+1;
counter++;
}
cout<<Letter;
to tell u the truth,i really don't know how to display those letters LOL :P
|
|
|
|
|
UKM_Student wrote: char Letter1,counter=1,Letter,a;
char Letter1 = 'A'; UKM_Student wrote: while((counter<=26))
{
Letter1=a;
Letter=Letter1+1;
counter++;
}
cout<<letter;< blockquote="">
while (Letter1 <= 'Z')
{
cout << Letter1 << endl;
Letter1++;
}
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|