|
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
|
|
|
|
|
Thanks its working better now,
Its not opening the working Directory
It’s using the executing directory as working directory
<br />
Public Function ExecuteAndWait(cmdline$)<br />
<br />
Dim NameOfProc As PROCESS_INFORMATION<br />
Dim NameStart As STARTUPINFO<br />
Dim x As Long<br />
Dim WorkingDirectory As String<br />
WorkingDirectory = "c:\"<br />
'MsgBox WorkingDirectory<br />
NameStart.cb = Len(NameStart)<br />
<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 />
<br />
End Function<br />
thats strange, any idee ?
thanks for your time
Greets jeroen
|
|
|
|
|
The open dialog is using the executing directory, not the directory from which the application was "launched", which would be the "working directory". This app is apparantly setting this internally. If that's the case, your not going to be able to change that.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Correct, im testing the function with notepad
(using windows XP)
its working now
i need this function for another
program (slow loading game)
Thanks for your help
Greets jeroen
|
|
|
|
|
I have the hWnd for another window, not part of my application, and I need to get the icon that explorer.exe is using for the window's icon in the task bar. It needs to be in a form that I can use it to create a system tray icon.
VB6 or .Net is fine.
|
|
|
|
|
To get the ICON of a EXE file use API Function: SHGetFileInfo()
|
|
|
|
|
You'll have to extract the icons out of the resources of the target app's .EXE. You can't get an application to given up it's running icon so easily. You'll end up trying to read the memory of another process and that's not easily allowed in Windows.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks for the help, but I think both of you are looking at this the wrong way.
Extractoing icons from the exe would work, but if there was more than one icon I wouldn'y know which to use. The application's icon is not alwayse the window icon.
Shell replacements seem to have no problems getting the icon for a running window... The following code is from Soft Shell Logi - a VB6 shell replacement: (Declarations neglected)
<br />
Private Sub DrawIcon(HDC As Long, hwnd As Long, X As Integer, Y As Integer)<br />
ico = GetIcon(hwnd)<br />
DrawIconEx HDC, X, Y, ico, 16, 16, 0, 0, DI_NORMAL<br />
End Sub<br />
<br />
Public Function GetIcon(hwnd As Long) As Long<br />
Call SendMessageTimeout(hwnd, WM_GETICON, 0, 0, 0, 1000, GetIcon)<br />
If Not CBool(GetIcon) Then GetIcon = GetClassLong(hwnd, GCL_HICONSM)<br />
If Not CBool(GetIcon) Then Call SendMessageTimeout(hwnd, WM_GETICON, 1, 0, 0, 1000, GetIcon)<br />
If Not CBool(GetIcon) Then GetIcon = GetClassLong(hwnd, GCL_HICON)<br />
If Not CBool(GetIcon) Then Call SendMessageTimeout(hwnd, WM_QUERYDRAGICON, 0, 0, 0, 1000, GetIcon)<br />
End Function<br />
Is there a way I can use DrawIcon to draw to a bitmap and create the icon for use in the system tray?
|
|
|
|
|
Since you got the handle to the icon, just can try (.NET):
Dim bmpIcon As Bitmap = Bitmap.FromHicon(handle returned by your GetIcon)
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I figured out fully the functions of this call through the use of for loops. This is great but there is a speed issue when handling the functions of this dll through for loops. I am just wandering if annoy one knows how to make this call work in .NET. The declare in vb 6.0 is
Private Declare Sub CopyMemory Lib "kernel32.dll" Alias "RtlMoveMemory" (ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)<br />
This is what i am having to work with. As anyone should know that the datatype
is not supported in .net. So i replaced it with the Object datatype.
a call to this dll function looks like this
<br />
Dim bytearray(3) as Byte<br />
dim bytearray2(3) as Byte<br />
<br />
Copymemory(bytearray(0), bytearray2(0), 4)<br />
This function copys all data starting with bytearray2(0) to bytearray(0) then
bytearray2(1) to bytearray(1) and so on until it copys 4 times. As you can see this can be done with a for loop. But say you have to run thought that for loop 1000 times. The Dll call is much more efficient. When i do it in the manner that i am now my processor sits at 100 percent for almost 3 seconds while it goes through these loops. In 6.0 using the dll call there is no wait and no processor jump. I need this call to work for program efficiency. Any help would be great. Thank you
|
|
|
|
|
The problem is you CAN'T use this function on managed objects and variables in .NET. The address you provide is not guaranteed to be the address of your object when the call to CopyMemory if made. The speed issue your having is because your marshaling objects back and forth between managed and unmanaged code.
Youe best bet is to trace through the code in VB6, and step by step, follow what happens to the array, then duplicate the steps necessary to perform the same thng in managed code. You'll be writing extra lines of code to do this, but you'll also gain a nice performance benefit by doing it either of there two ways.
So instead of CopyMemory from bytearray2 to bytearray0, you would just do:
bytearray(0) = bytearray(2)
bytearray(1) = bytearray(3)
bytearray(2) = bytearray(4)
bytearray(3) = bytearray(5)
You could also do this:
Array.Copy( bytearray, 2, bytearray, 0, 4)
You'll have to test each method to find out which is going to give you the greatest performance benefit, but both will be MUCH better than calling an unmanaged function on a managed object...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I would like to limit user using the System Menu CANCEL box in order to force them using CANCEL button instead! I can disable MINIMIZE & MAXIMIZE boxes but I can not disable CANCEL box in Property of System.Window.form... anyone knows how to do it?
Thanks,
|
|
|
|
|
Make the ControlBox property of the Form False.
|
|
|
|
|