|
How to access all list of contacts ?
|
|
|
|
|
I need to programmatically copy a file from one computer to many others and it needs to be done simultaneously. I've tried the .Net File.Copy Method but i found out it cannot copy an already open file. How do I copy an currently open file?
Thanks
|
|
|
|
|
If the open file is locked in read/write mode, you will not be able to copy it until the lock has been released.
As for simultaneous copying, you'll be using System.Threading.Thread class.
Regards,
Serge (Logic Software, Easy Projects .NET site)
|
|
|
|
|
if you use visual basic or visual c++ you can use api to copy or delete or move file in same pc or to another pc
and to use it by vb use this
Public Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal bFailIfExists As Long) As Long
and in vc++ just call the fucnction
|
|
|
|
|
If the file is locked by an application as ShareDenyRead or ShareDenyAll, then your screwed and have to wait for the application to release it's locks or, preferrably, closes the file.
If your going to copy this file to multiple locations simultaneously, you can do it by either P/Invoking the CopyFileA function for each destination computer, letting the O/S copy the file. Or you can create your own copy file class and launch a copy on a thread for each destination.
In either case you'll have to watch how many of these you launch at one time. If you try an launch this for, say, 25 machines at one, you'll bring your system to a halt waiting for these things to copy out. Whatever network connection you use will quicky become saturated with your copy traffic and you, most likely, won't be able to do much of anything else until the copy process is completed.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I am using a max 10 threads to copy this file to other pcs and the only application using this file is my application. I've tried using the API but it still won't work. I am looking for a way to copy this file similar to the way the Backup applications doing it. Any suggestions?
Thanks again.
|
|
|
|
|
OK. You seem to believe that Backup programs can backup any file they want, regardless of its locked state. This is simply not true. If an application has a file locked for exclusive read and/or write, the backup application will normall skip the file. There are occasions where a locked file CAN be backed up, but these include files where there are record locks, not entire file locks, and file that are locked for write, but shared read. Some backup apps also install extensions to the file system to partially get around these limitations, but the techniques involved require low level disk access and assembling the file from the disk sectors into another file.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Another Question: How do use the shadow copy service in Windows 2003 from a VB.NET application? Just curious.
Thanks to all!!!
|
|
|
|
|
Is there an event (or related event) triggered when you edit the contents of a cell in a bound datagrid (VB.NET). I am trying to update the total value of the columns in the last column...
|
|
|
|
|
Dim objP(255) As Login 'Login is a class
'Here I want to use the class sub "SetValues"
objP(1).SetValues("Bla1", "Bla2")
'Here i want to show the class member "User"
MsgBox(objP(1).User)
But this results in this error message:
---
An unhandled exception of type 'System.NullReferenceException'
occurred in ClassApp.exe
Additional information: Object reference not set to an instance
of an object.---
I wonder if I should use something like this to make it work?
Dim objP(255) New As Login -But this doesn't work!
Thanks for help!
//Ari
|
|
|
|
|
You need to instantiate every member of the array, like this
Dim i as Integer<br />
<br />
for i=lbound(objP) to ubound(objP)<br />
objP(i) = new Login<br />
next
Do you always need all the 255 Logins ? If not, I'd prefer using an ArrayList or a Collection.
dim logins as New ArrayList()<br />
<br />
logins.Add(new Login("Bla1", "Bla2"))
Regards,
Serge (Logic Software, Easy Projects .NET site)
|
|
|
|
|
I have an application that I debugged initially in Windows XP, and I am now testing it on Windows 2000 Professional. There are two things that don't work correctly in Windows 2000:
1) The first time the app is opened, the splash screen doesn't close on the timer_tick event. If I close the app and re-open it, it works fine.
2)The cursor doesn't change using the syntax (from an MDI child form)
Me.Parent.Cursor = Cursors.WaitCursor
WHat do I need to do to make these features work properly in Windows 2000?
Thanks!
|
|
|
|
|
Is the 2000 box runnig with the lastest Service Pack?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I believe it is. It has Service Pack 4 installed.
|
|
|
|
|
In that case, I hove no idea. You shouldn't have to make any code changes to get the same functionality. I only mentioned the Service Pack because there was a problem with some timers under Windows 2000 that was fixed with Service Pack 2.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Where can i find good sites to learn vb.net step by step. And where can i find examples on vb.net with pictures.
Thanks.
Go forward and never Stop....
|
|
|
|
|
http://www.amazon.com[^]
How good the site, or other resource, is depends entirely on your skill set and how you learn.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
How do I find the list of computers in my network. Using VB 6.0
Every is Illusion
|
|
|
|
|
You'll have to call the Win32 API functions WNetOpenEnum, WNetEnumResources, WNetCloseEnum, along with a few others and a couple helper functions. There is an example of this in the Microsoft Knowledgebase here[^].
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi,
Is there Microsoft provided funtion which will give me woking days in a year. e.g. With 5 days working week, how many daysare there in year
~@lh
|
|
|
|
|
Not that I know of, but it is not difficult to work out:
52 weeks * 5 days
+ 1 day if 31st Dec is a working day
+ 1 day if 30th Dec is a working day AND it is a leap year.
From there you can subtract local holidays if necessary.
Does this help?
"You can have everything in life you want if you will just help enough other people get what they want." --Zig Ziglar
The Second EuroCPian Event will be in Brussels on the 4th of September
Can't manage to P/Invoke that Win32 API in .NET? Why not do interop the wiki way!
|
|
|
|
|
I can't get lpCurrentDirectory to work correct
why ?
This option is provided primarily for shells that need
to start an application and specify its initial drive and
working directory.
<br />
'Declare CreateProcess<br />
Type STARTUPINFO<br />
cb As Long<br />
lpReserved As String<br />
lpDesktop As String<br />
lpTitle As String<br />
dwX As Long<br />
dwY As Long<br />
dwXSize As Long<br />
dwYSize As Long<br />
dwXCountChars As Long<br />
dwYCountChars As Long<br />
dwFillAttribute As Long<br />
dwFlags As Long<br />
wShowWindow As Integer<br />
cbReserved2 As Integer<br />
lpReserved2 As Long<br />
hStdInput As Long<br />
hStdOutput As Long<br />
hStdError As Long<br />
lpCurrentDirectory As Long<br />
End Type<br />
Type PROCESS_INFORMATION<br />
hProcess As Long<br />
hThread As Long<br />
dwProcessID As Long<br />
dwThreadID As Long<br />
End Type<br />
<br />
Global Const BELOW_NORMAL_PRIORITY_CLASS = &H4000&<br />
Global Const HIGH_PRIORITY_CLASS = &H80&<br />
Global Const IDLE_PRIORITY_CLASS = &H40&<br />
Global Const NORMAL_PRIORITY_CLASS = &H20&<br />
Global Const REALTIME_PRIORITY_CLASS = &H100&<br />
Global Const INFINITE = -1&<br />
Declare Function CloseHandle Lib "kernel32" (hObject As Long) As Boolean<br />
Declare Function WaitForSingleObject Lib "kernel32" (ByVal hHandle As Long, ByVal dwMilliseconds As Long) As Long<br />
Declare Function CreateProcessA Lib "kernel32" _<br />
(ByVal lpApplicationName As Long, ByVal lpCommandLine As String, ByVal lpProcessAttributes As Long, ByVal lpThreadAttributes As Long, ByVal bInheritHandles As Long, ByVal dwCreationFlags As Long, ByVal lpEnvironment As Long, ByVal lpCurrentDirectory As Long, lpStartupInfo As STARTUPINFO, lpProcessInformation As PROCESS_INFORMATION) As Long<br />
<br />
Public Function ExecuteAndWait(cmdline$)<br />
On Error GoTo Error<br />
Dim NameOfProc As PROCESS_INFORMATION<br />
Dim NameStart As STARTUPINFO<br />
Dim x As Long<br />
NameStart.cb = Len(NameStart)<br />
x = CreateProcessA(0&, cmdline$, 0&, 0&, 1&, HIGH_PRIORITY_CLASS, 0&, 0&, NameStart, NameOfProc)<br />
x = WaitForSingleObject(NameOfProc.hProcess, INFINITE)<br />
x = CloseHandle(NameOfProc.hProcess)<br />
Exit Function<br />
Error: ' Error handling<br />
MsgBox "Run-Time Error number " & Err.Number & vbCrLf & Err.Description, vbOKOnly + vbCritical, "CreateProcess<br />
"<br />
End Function<br />
Thanks for any help
Greets jeroen
|
|
|
|
|
You never said what you expect the current WorkingDirectory to be or what the problem is with it. Besides, your code isn't even using it in the CreateProcessA call. Your passing 0 in as the pointer to the lpCurrentDirectory parameter.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Oke lets passing another parameter
<br />
Public Function ExecuteAndWait(cmdline$)<br />
<br />
Dim NameOfProc As PROCESS_INFORMATION<br />
Dim NameStart As STARTUPINFO<br />
Dim x As Long<br />
Dim A<br />
Dim WorkingDirectory As String<br />
<br />
WorkingDirectory = cmdline$<br />
'MsgBox WorkingDirectory<br />
<br />
<br />
NameStart.cb = Len(NameStart)<br />
x = CreateProcessA(0&, cmdline$, 0&, 0&, 1&, HIGH_PRIORITY_CLASS, 0&, WorkingDirectory, NameStart, NameOfProc)<br />
x = WaitForSingleObject(NameOfProc.hProcess, INFINITE)<br />
x = CloseHandle(NameOfProc.hProcess)<br />
End Function<br />
it gives this error code:
run-time error 13
Type mismatch
Why ? im missing somthing ?
Thanks for your time
Greets jeroen
|
|
|
|
|
This is the Declare you used for CreateProcess:
Declare Function CreateProcessA Lib "kernel32" _
(ByVal lpApplicationName As Long, _
ByVal lpCommandLine As String, _
ByVal lpProcessAttributes As Long, _
ByVal lpThreadAttributes As Long, _
ByVal bInheritHandles As Long, _
ByVal dwCreationFlags As Long, _
ByVal lpEnvironment As Long, _
ByVal lpCurrentDirectory As Long, _
ByRef lpStartupInfo As STARTUPINFO, _
ByRef lpProcessInformation As PROCESS_INFORMATION) _
As Long
Now your trying to pass a String where your Declare said your going to pass a ByVal Long. Change it so that it reads:
ByVal lpCurrentDriectory As String
BTW, the correct Declare out of the VS6 APIViewer is this one: Your version will work so long as you pass the parameters the function expects in the format that it expects.
Public Declare Function CreateProcess Lib "kernel32" Alias "CreateProcessA" _
(ByVal lpApplicationName As String, _
ByVal lpCommandLine As String, _
ByRef lpProcessAttributes As SECURITY_ATTRIBUTES, _
ByRef lpThreadAttributes As SECURITY_ATTRIBUTES, _
ByVal bInheritHandles As Long, _
ByVal dwCreationFlags As Long, _
ByRef lpEnvironment As Any, _
ByVal lpCurrentDriectory As String, _
ByRef lpStartupInfo As STARTUPINFO, _
ByRef lpProcessInformation As PROCESS_INFORMATION) _
As Long
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|