|
Hello to all..
I am doing a program that a time carried out some operations on the pc. ..creates a txt in which contains some info on the procedure...
And here all outcome ok. ...
The problem is that when the file is compiled, I should send it to a server....but to make this I should await that the file is concluded.
Now I wonder: I know that until the end of the procedure the file size is 0 KB and a time concluded, it is immediatly replenished in approximately 300 KB... it's possible to establish (maybe with a loop...), until the file size is equal to 0 KB ---> do ACTION 1; when the same file is DIFFERENT from 0 KB (does not matter myself how much is big. ..) then do ACTION 2......
It is possible in your opinion?
Thanks to all..
Night Soul!!!
|
|
|
|
|
Let me see if I understand you...
You want to monitor the size of a file, and based on its size, you want to determine if it's safe to copy the file to another server and then erase the file and let the other app recreate it.
Correct? It's possible... but a questionable technique.
A better method would be to try and rename the file constantly. If the file is open, the rename will fail. When the rename finally succeed's, you accomplish two things. One, the file is immediately taken out of the way of the other application, freeing it to create another one. Second, you now have exclusive rights to the renamed file because the other applications know nothing of the new name. You are free to do whatever you want with this renamed file, like copy it to a server, and if the server is not available at the time of the copy, store the file locally to be copied up later.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I don't want to make exactly what you mean....
I Try to explain me.....
I must upload a file on a server....but the process that create it use a few minutes to conclude the file....
I try all the way I now...but at a certain point there is an error..."the file is being used from another process"...
I must know exactly when the procedure terminate....
It was for this reason that had thought to do a loop that until the file size is = 0 do ACTION 1, instead when the file is full you do ACTION 2..
Excuse me again for my bad english....but can you understand me now?
I hope....
tynx a lot.....
Night Soul!!!
|
|
|
|
|
What is ACTION1 and ACTION2?
If the file is opened by the process exclusively, there won't be any ACTION on the file until the other process closes it. Just checking the file size is not a good of that. The file sits at zero until the app and the O/S flushes it's buffers, but the app doesn't have to close the file to do that. The file size will rise, but will still be open by the app...
That's why I say you have to try and open the file to determine when it is actually closed by the other app. Until the other app closes it, you WILL get "the file is being used by another process", or an Exception, that you must handle in your code in order to find out when the other process closes the file.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I paste the loop I have in mind...Why it does not work?
Sub LoopSize()
Dim i As Integer
i = 0
Const FILE_SIZE = FILE_PC_INFO
Dim Peso_File As FileInfo
For i = 0 To 0
If FILE_SIZE.Length = 0 Then
Thread.Sleep(3000)
Else
MsgBox("THE FILE IS COMPILED!!!")
Thread.Sleep(3000)
i = i + 1
End If
Next
End Sub ' LoopSize
*** FILE_PC_INFO is myinformationsfile.txt ***
does it help understand me?
Night Soul!!!
|
|
|
|
|
Your loop does not execute. If you need a loop the executes forever, use
Do While True<br />
' check file size here<br />
' ...<br />
' *****<br />
<br />
If FILE_SIZE.Length = 0 Then<br />
Thread.Sleep(3000)<br />
Else<br />
MsgBox("THE FILE IS COMPILED!!!")<br />
Exit Do<br />
End If<br />
Loop
Regards,
Serge (Logic Software, Easy Projects .NET site)
|
|
|
|
|
|
I am working with a 3rd party app that takes focus when it needs to perform certain tasks. The problem with this is if the user presses the ESC key the application needs to be reloaded.
Is there an easy way to disable the ESC key before it takes focus and then re-enable it when focus is returned to my app?
Thanx for all the input...
t
|
|
|
|
|
Easy? No... You'll have to write either a keyboard hook that looks at every keystroke and doesn't pass on the ESC key, or write a Message Filter that implements IMessageFilter to do the same thing.
The keyboard hook is harder to write...
The docs for the MessageFilter starts here[^].
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Dave, excuse me but can you explain me, what a keyboard hook is?
tnx!;)
Night Soul!!!
|
|
|
|
|
A keyboard hook is a function that you write and register with Windows using the SetWindowsHookEx API function. Basically, this function will be called every time the keyboard driver attempts to post a keyboard message to an input queue. You can see every keystroke message before it goes to an application. This function has a responsibility of passing along the data that the driver has given it to the next hook in the chain. (You can have multiple hooks attached, where each hook has to pass the data it receives to the next...)
The cool part is you can manipulate the message data before it's passed to the next hook. Or, if you need to disable certain keys, DON'T pass the data to the next hook. Just return nothing...
I've written hooks to disable the Windows Logo keys, eat certain keystrokes at certain times, and have even had a little fun, like 5 times a second, replace the WM_KEYDOWN message with a different key than was hit... Drives people nuts when they don't know you installed it!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
thanks for the lesson!!!;)
well done!
Night Soul!!!
|
|
|
|
|
Hi everybody,
I've a simple question to you:
If two or more applications are running, and I want to get a refernece to a specific one, how can I do that
e.x
Two MS Word are running
and I want to GetObject (, "Word.Application"), of course that depends on who runs first.
the question is
How can I get always the application tha I want ?
Thanks in advance.
Carlos Mariano
Carlos Mariano
|
|
|
|
|
Are you saying that you want to retrieve a specific instance of Word that is already running? You can't. There is no way to get a reference to a specific instance of an object. If it's Word that your trying to get, only one copy of it is ever running at any one time. Once you get the reference to Word, you can use the Word object model to pick the document you want from its Documents collection.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
It sounds logic, what about avoiding to run two or more word instances .
Is tit possible ?
Thanks!
Carlos Mariano
|
|
|
|
|
You CAN'T run more than one instance of Word. Word, itself, takes care of this. If you try to open multiple documents at the same time, Word will open just once and load all the documents seperately and manage them. This is what the MDI model (Multiple Document Interface) model is all about.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I know that, word was an example, may be a bad example, but there'a application tha you can run more than once at the same time.
You may want to have multiple mdi application or not ?
the queastion was if you have sutch application is it possible to get one expecifically
Thanks
CM
Carlos Mariano
|
|
|
|
|
In that case, no you can't get a specific instance.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
How can I track email addresses from a send message and then store that particular address in a database table
jaya
|
|
|
|
|
Where is the address going to come from?
There only thing your going to be able to do to accomplish this is write your own mail server service that run locally on the machine. This sounds like alot of work to do something seemingly so simple, but I'll explain why it needs to be done this way.
If you write an extension to Outlook, your idea will only work for Outlook. It will NOT work for Eudora, Navigator, or any other email package. So you need something to sit between ALL the possible mail clients (except web mail like Yahoo or Google mail!). Plus, writing an extension for Outlook is not that easy and you'll have to write an assembly inside of a COM Callable Wrapper.
The best solution is to write a mail server service that runs on the local machine. Outlook, or any other mail package, will be setup to get/send it's mail from 127.0.0.1 (the local IP for the machine). You can use any ports you want to the POP3 and SMTP listeners, but usually the port numbers used are going to be in the thousands range somewhere. For example, your POP3 server will listen on port 2525 and the SMTP server will listen on 2626. Outlook will send and retrieve it's mail from this server. Your server will then take these messages and do whatever processing it needs to, like get the to/from addresses and store them in a database. It will then have to relay the messages to the REAL mail server on it's normal ports.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Sub DisplayCustomer(ByVal position As Integer)
Dim node As XmlNode = xmlDoc.SelectSingleNode( _
"/Customers/Customer[" & position & "]")
txtCustomerID.Text = node.SelectSingleNode("@ID").InnerText
txtContactName.Text = node.SelectSingleNode("ContactName").InnerText
txtPhone.Text = node.SelectSingleNode("Phone").InnerText
End Sub
I'm not a VB programmer, but I was checking out this code. What does the "_" do in the 2nd line do?
Thanks.
/\ |_ E X E GG
|
|
|
|
|
That is a "contine on next line operator"
In C++ it is not needed because ; is the eol marker, but in VB, each individual line is assumed to be self-ending. Thus, a " _" operator is sometimes necessary for a long line.
Aaron Eldreth
TheCollective4.com
My Articles
While much is too strange to be believed,
Nothing is too strange to have happened.
- T. Hardy
|
|
|
|
|
Since the line will be long if you put all in one line, instead, "_" helps you to write the code on a new line.
It is the same as:
Dim node As XmlNode = xmlDoc.SelectSingleNode("/Customers/Customer[" & position & "]")
|
|
|
|
|
i am tryin to convert a project that was made in 6.0 to .net and its a little tough. I was wondering if anyone knew of a way to mimic the function of the varptr in some way.
i have been trying to use the RTLmoveMemory dll call but in .net it is almost impossible to make it function. So i have been working to figure out how this function actually works. I would say i have it almost 75 percent pinned but when you send negative numbers to it comes back with numbers that i havent been able to put a mathmatical equation too. If there is any help with that it would be great.
Public Declare Sub CopyMem Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal Length As Long)
but anycase i need to know how to use the varptr function because in the following snippet heres the problem and the reason i need to use it
<br />
For i = 0 To (ROUNDS + 1)<br />
dataX = 0<br />
For K = 0 To 3<br />
Call CopyMem(ByVal VarPtr(dataX) + 1, dataX, 3)<br />
dataX = (dataX Or Key(j))<br />
j = j + 1<br />
If (j >= KeyLength) Then j = 0<br />
Next<br />
m_pBox(i) = m_pBox(i) Xor dataX<br />
Next
rounds = 16
key contains a unicode work "text1"
key(0) = 116
key(1) = 101
key(2) = 120
key(3) = 116
key(4) = 49
when it first interates through the second for loop datax = 116
which is the first number in the byte array
but i have no idea where these other numbers are coming from
2 datax = 298313
3 datax = 7632253
4 datax = 1953856893
if i can figure out what varptr(datax) + 1 does and mimic its function and also figure out why when negative numbers are send to the api call it sends back really negative large numbers. Any help with any thing seen here would be awesome. thank you very much
|
|
|
|
|
VarPtr has no equivelent in VB.NET... All it does is return the address of the variable, which, in managed code, is not guarenteed to stay where it was created thereby invalidating the return of VarPtr.
What you would have to do is, in VB6, step through this code and watch what happens to dataX. the variable dataX looks like it is a Long, or Integer in VB.NET...a 32-bit signed integer. What it looks like it's doing is copying bytes 2, 3, and 4 to byte 1 of dataX. It might help to look at the value of dataX in the Watch window in Hexadecimal.
dataX before CopyMem dataX after CopyMem
byte1 | byte2 | byte3 | byte4 byte1 | byte2 | byte3 | byte4
2B 1A 00 FE 1A 00 FE FE
In this case, what you would need to do is mask out byte 1, 2, and 3 to get the value of the 4th byte. Then move the numbers in dataX to the left by 8 bits and finally add back in the lastByte:
' From the example above...
Dim dataX As Integer = &H2B1A00FE
Dim lastByte As Integer = (dataX And &H000000FF) ' lastByte will equal &HFE.
' This moves the data left 8 bits. This will drop the first byte and move
' the remaining bytes to the left, leaving 00 in the last byte.
' 2B1A00FE becomes 1A00FE00
dataX = dataX * 256
' Now add back in, the byte that we saved above.
' 1A00FE00 becomes 1A00FEFE
dataX = dataX + lastByte
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|