|
I belive lot of other apis like this one is OS dependened.
Tech.Support : Mam, is your pc running under windows?
Customer : No actually its close to the main door.
|
|
|
|
|
I am having a difficult time trying to get a value to increment. What I mean is if I have a static control for example called CValue that each time a button is pressed it will increase the value by one. So if CValue = 10 and the button is pressed, I want it to change the value of CValue to 11. Each time I try to do this, the compiler says some crap about converting CString to an int is impossible or something. I cannot remember because I just got out of bed to write this so that I may have a reply by the morning.
Can someone please help me. I know this is easy 'i think' but it has me tickled pink.
Thankyou
Ashman
|
|
|
|
|
Have you tried something like:
CString strValue;
CValue.GetWindowText(strValue);
int nValue = atoi(strValue) + 1;
CValue.SetWindowText(strValue);
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
DavidCrow wrote:
CString strValue;
CValue.GetWindowText(strValue);
int nValue = atoi(strValue) + 1;
CValue.SetWindowText(strValue);
Whoops!
CString strValue;
CValue.GetWindowText(strValue);
int nValue = atoi(strValue) + 1;
strValue.Format(_T("%d"), nValue);
CValue.SetWindowText(strValue);
INTP
|
|
|
|
|
No, BIG whoops! Thanks.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
What about GetDlgItemInt()?
SetDlgItemInt(IDC_MYCONTROL,MyCtrl.GetDlgItemInt(IDC_MYCONTROL) + 1);
onwards and upwards...
|
|
|
|
|
hello together,
i have a strange problem with the following asm command;
__asm call 0h
This command should jump to the next instruction and put the value of the position where the last call was made onto the stack! Well, it should, but i only get this message:
error C2415: improper operand type
Any ideas?
Thanks in advance!
|
|
|
|
|
How about:
__asm
{
call 0h
}
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
|
Indeed. It used to be that you had to do it that way (whether that was with Borland's compiler or Microsoft's compiler, I forget), but I've not done inline assembly in nearly a decade.
Are you sure that is a valid statement (for an Intel platform)?
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
I have a program that manages documents on a central area in the network and I need to tell if a file is in use by someone ele, when I try to open it. The program runs on each machine that access the central archive (no program runs on the server that holds the files). What is the right or the best way to do it ? Can I try to lock the file or rename it and see by the error returned if the file is open ? Is there any API function that tells me that ? If it´s a Word Doc, for instance, the Word gives me a hint, but Notepad doesn´t. I want to send my own msg to the user, despite of the app used to open the file. Is it possible ?
|
|
|
|
|
check out sdk's CreateFile() proc. if specified file is somehow locked, you get an invalid handle. you may then call GetLastError():
hope this helps...
|
|
|
|
|
or you could look at good old _sopen, passing the _SH_DENYRW flag
onwards and upwards...
|
|
|
|
|
hello,
i want to install my application (.exe) in a remote m/c. how to first copy the exe file to the remote m/c... .i know that a service is required to install & start in the remote m/c . now i want to install that remotely . how do i achieve that.???? please tell me how to install the application remotely ...i need it urgent.
please send code , article... urls...
|
|
|
|
|
skpanda wrote:
how to first copy the exe file to the remote m/c
How about CopyFile() , MoveFile() , or SHFileOperation() ?
For the rest, it sounds like you'll need RPC.
A rich person is not the one who has the most, but the one that needs the least.
|
|
|
|
|
Hello guys,
I think there is a bug in C++.
I had a very strange bug in my app but I fixed it..
What happened was somewhere in my code I wrote:
CString sTemp;
...//doStuff
sTemp = ((A_INTEGER == myObj.GetIntValue())? GetString("1"):GetString("2"));
...do more stuff
What happened now was that I used that sTemp string to put text in a list-control...
when I used the statement shown above and R1C2(Row1Column2) was filled with GetString("2") and R2C2 was filled with GetString("1") then in R1C5 the leftmost character was deduced by 1... When also R3C2 was filled with GetString("2") then R1C5 was deduced by 2 and so on...
in the other way no bug appeared....
The ONLY change I made in the code was that I replaced the line:`
sTemp = ((A_INTEGER == myObj.GetIntValue())? GetString("1"):GetString("2"));
with:
if(A_INTEGER == myObj.GetIntValue())
sTemp = GetString("1");
else
sTemp = GetString("2");
Which is still basically the same thing just in a different notation...
Does anyone know why this bug appeared?????
Any comments are welcome....
Greetings,
A puzzled programmer....
|
|
|
|
|
first of all c ain't software, so it cannot contain any bugs.
this maybe sth caused by your compiler.
have you checked out this:
sTemp = GetString((A_INTEGER == myObj.GetIntValue())? "1" : "2");
??
|
|
|
|
|
Hi,
I need to write an application that is able to access the network as soon as networking is available. On NT class systems that's not a problem, I can just have a service and the network is available as soon as the machine boots up, be it an http address or a UNC path.
On 9x the problem is a bit trickier. I can still have an application that behaves like a service and that's run as soon as the computer boots up, but I am not able to access UNC paths until the user has loggend on into the network.
So the question is: is there a way to detect when the user logs on to the network (be it a callback, a message broadcasted, and event, whatever)? I could possibly hook on the logon window and intercept the clicking of 'OK', but that only starts the logging on and I don't know how long that takes.
Any ideas?
Thanks,
Alberto
|
|
|
|
|
Hello!
Try to catch message WM_DEVICECHANGE with DBT_DEVTYP_NET
Hope that it will help.
|
|
|
|
|
hai everybody,
I am doing a project in VC++.
for that i have came accross a trouble.
How to draw a CButton with a backcolor and
a icon on that button.
|
|
|
|
|
|
Interesting issue when using FindFirstChangeNotification and FILE_NOTIFY_CHANGE_FILE_NAME.
I have two threads. Every so often thread A creates a temp file and then uses the MoveFile API command to move the file to a specific folder. Thread B is watching said folder via FindFirstChangeNotification/FILE_NOTIFY_CHANGE_FILE_NAME. When the file appears in the folder, thread B wakes up and processes the file. However, on some PCs, thread B fails to open the file - GetLastError returns 32 - "File in use by another process". I can only imagine that thread B is getting FILE_NOTIFY_CHANGE_FILE_NAME mid-way through the MoveFile. Not sure what to do about this - keep trying to open the file until it succeeds? Tacky. Note I am only getting one FILE_NOTIFY_CHANGE_FILE_NAME notification - so I can't ignore it if the file open fails in the hope I will get another one later.
Stumped. I guess, as this is one app, thread A can call a therad-safe function in thread B and add the file to a list protected by a critical section or something, but this is a fair amount of re-engineering.
Anyone else come across issues like this with FindFirstChangeNotification?
The Rob Blog
|
|
|
|
|
I haven't hit this using FindFirstChangeNotification but I've hit similar problems. I wouldn't keep trying to hit the file until success - as you say, that's tacky.
I've done this only in timed loops - a call to WaitForSingleObject or a call to WaitForMultipleObjects where the loop was intended to run every so often. I've always treated a fail on error 32 as a benign failure and left it to future passes through the loop to handle it.
I notice you say you can't ignore the error because you won't see the notification again. How about launching a thread to monitor the file? You could monitor multiple files in the one thread with reasonable (for your application) sleeps between passes over the locked files.
Rob Manderson
http://www.mindprobes.net
Paul Watson wrote:What sense would you most dislike loosing?
Ian Darling replied.
Telepathy
Then I'd no longer be able to find out everyones dirty little secrets The Lounge, December 4 2003
|
|
|
|
|
Rob, thanks for the response.
I want to keep threads to a minimum as the app already spawns plenty, especially when busy. What I am really after is a reliable way to use FindFirstChangeNotification so I am notified when a new file appears in a folder AND is safe to open!
I think I am going to have to re-engineer the app to allow both threads access to a list of files...
The Rob Blog
|
|
|
|
|
I understand the reluctance to spawn yet another thread. The situation I found myself in was that our application processed a file and then deleted it. Often the file wouldn't delete because some other process had an open handle on it so we had to defer the deletion. My solution was to write a class CDeferredFileDelete that tried to delete the file. If it succeeded well and good. If not, it passed the filename to a service and forgot about it. The service was then responsible for deleting the file at some future time. Hmmm maybe I have an idea for another article
In the situation I'm talking about it was relatively simple - the file was marked for deletion and it didn't much matter when the delete occurred just as long as it did occur. Your situation is somewhat different and I don't really know how (short of a seperate thread) to determine that a new file has appeared and is safe to open.
I think I'd approach it by using the notification to add a file object of some sort to a queue controlled by another thread, and have that thread try to open the file in exclusive mode. If success, close the file and add it to a work queue. If fail, try again in the next pass through the loop. Which is not much different from what I've already suggested
I can't think of a better approach.
Rob Manderson
Paul Watson wrote:What sense would you most dislike loosing?
Ian Darling replied.
Telepathy
Then I'd no longer be able to find out everyones dirty little secrets The Lounge, December 4 2003
|
|
|
|