|
For the code below, I always get an empty string from "GetWindowText()" call, instead of getting the caption or title of the window.
Not sure, why am I getting that empty string?
Any help is appreciated.
Thanks.
===========================================
hProcess = OpenProcess(PROCESS_QUERY_INFORMATION Or PROCESS_VM_READ, 0, ProcessIDs(0))
If hProcess <> 0 Then
lRet = EnumProcessModules(hProcess, Modules(1), 200, cbNeeded2)
If cbNeeded2 > 500 Then
cbNeeded2 = 500
End If
If lRet <> 0 Then
For j = 1 To cbNeeded2
ModuleName = Space(MAX_PATH)
nSize = 500
x = GetWindowTextLength(hProcess)
str = Space$(x)
x = GetWindowText(hProcess, str, x)
tl_dt_GetPID = ProcessIDs(0)
lRet = CloseHandle(hProcess)
Exit Function
Next j
End If
End If
lRet = CloseHandle(hProcess)
End Function
|
|
|
|
|
See my reply in the other thread...
RageInTheMachine9532
|
|
|
|
|
I am attempting to stong name my first assembly. I found the Sn.exe utility,but can't seem to open it. When I try, it flashes on the screen and then disappears. The reference book I am using is very vague on how to use the utility. what am I doing wrong?
Please respond as soon as you can, I need to get the deployment done so I can get this application to my associates!
Thanks!
|
|
|
|
|
That's because SN is a command line utility. It doesn't have a window interface. Go to Start/Programs/Microsoft Visual Studio .NET (2002|2003)/Visual Studio .NET Tools and click on Visual Studio .NET (2002|2003) Command Prompt. Then type your SN command in there.
RageInTheMachine9532
|
|
|
|
|
Thanks!
Now I have another problem. My application references both Interop.Excel and Interop.VBIDE. after I assigned a strongname key pair to the (2) assemblies I wrote, I tried to build the solution, and got a build error saying that I needed to strong name these two assemblies. How do I do this?
Thanks Again!
|
|
|
|
|
Hi,
From VB, how can we kill a particular process, given the following scenario:
I see 2 applications, say cmd.exe in task manager and only one of them is of my concern, which I would like to kill from VB.
How can I distinguish this cmd.exe from the other. Note that I dont know which one to kill just by looking at it and also the process ID's change everytime I restart an application which generates this cmd.exe
Any help is appreciated.
Thanks.
|
|
|
|
|
In simple terms, you can't tell them apart unless there is a property that is unique to the process your trying to kill, like MAYBE its MainWindowTitle.
Use the Process class to get the list of processes. You can then use the Close method on the instance of Process to terminate that process.
RageInTheMachine9532
|
|
|
|
|
OK thanks,
The process cmd.exe is generated from VC++.
So I added the title bar from VC++ using
STARTUPINFO.lpTitle = "foo";
And from VB I used GetWindowText(), but it always gives back an empty string instead of the title(foo) of that process (cmd.exe).
I have defined GetWindowText() in VB as:
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hWnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Any clue why am I getting empty string back and not the title?
|
|
|
|
|
Sorry, I though you were using VB.NET.
Wait a minute... If you have the VC source, why not just kill the process from the VC app? After all, when you launch the process you get a ProcessHandle back. You use that ProcessHandle with the TerminateProcess function and your done.
RageInTheMachine9532
|
|
|
|
|
Well, there are some software architectural problems and paths which needs to be followed and this killing process is a specific scenario. Thus I cannot kill from VC.
Hence I need to kill it from VB...(its a long story, but in short, cannot kill from VC).
Sorry for the confusion..
|
|
|
|
|
Well, I've got an old VB6 source that will show you how to enumerate all the windows on the Desktop or your current app. It will also demonstrate GetWindowText. You can use the information gathered in this source to add to your code. You can use the window handle that is returned for your command window so you use SendMessage and WM_CLOSE to get the CMD window to close itself.
Just drop me a note at dkreskowiak1@(kill the stuff in parenthesis)comcast.net and I can send you the Zip'd source.
RageInTheMachine9532
|
|
|
|
|
Hi
I don't know.. But I create a crystal report usign VS.NET Enterprise Edition and put into my project. But when I want to request the crystal report It's not appear. I don't know what I doing wrong. Anyone can help on that or give some advise.
Thanks
Johnny Lizardo
|
|
|
|
|
The following link will allow you to register and download a be beginers guide which I found usefull when starting out.
http://www.crystalreportsbook.com[^]
Hope this helps.
Regards
Wayne Phipps
____________
Time is the greatest teacher... unfortunately, it kills all of its students
LearnVisualStudio.Net
|
|
|
|
|
Hi all
In my app i create modal dialog box
by call ShowDialog like here
...
dim res as DialogResult
res = dlg2.ShowDialog(Me)
//res always cancel
In properties of dlg2 i set AcceptButton and CancelButton to vary buttons on my form but when i press any of this one
i return in my code with same result res = Cancel
Is this studio bug???
Or i desperate silly???
And else
Which control i can use to be part my dialog on some frame.
Thanks
|
|
|
|
|
On your dialog form, check the OK and Cancel button's DialogResult properties and make sure that they are set to what you want them to. When these buttons are clicked they will copy their DiaglogResult properties to the Forms DialogResult, thereby getting passed back as the result of your ShowDialog call.
RageInTheMachine9532
|
|
|
|
|
I am developing a windows service which would check if a particular program is running and if not start the program as an application.
But I cant seem to able to get it.
I have used "Shell" but the service starts the program as a service running in the background and not as an application. How do I do that?
|
|
|
|
|
It's not working because the service is running on it's own desktop, not the one the user sees.
Currently, the .NET FCL does NOT support services that interact with the user desktop. You would have to P/Invoke the CreateProcess function to launch the app, but that would also require that the service runs under a user account and not the LocalSystem account.
RageInTheMachine9532
|
|
|
|
|
In my resize event i use Height to change the height of the object but i see that sometimes ScaleHeight is used. Why? What's the difference?
Grtz,
Guus
|
|
|
|
|
Use the Height, Width, Left, and Top properties for operations or calculations based on an object's total area, such as sizing or moving the object.
Use the ScaleLeft, ScaleTop, ScaleHeight, and ScaleWidth properties for operations or calculations based on an object's internal area, such as drawing or moving objects within another object.
RageInTheMachine9532
|
|
|
|
|
Before someone says something, I can´t use SSTab component. We are replacing all Sheridan components in our system.
I have a tabstrip with 5 tabs and a control array with 5 frames. For each tab there is a frame. When you clicks in a tab, it should show the relationed frame. But only the first frame is shown.
I debugged the code and I saw that the visible property of the second, third, fourty and fifty frames is not being changed.
The line below:
Frame1(n).visible = True
It only works for the first frame.
I don´t know what I do.
Flávio Gomes da Silva Lisboa
Programmer Analyst
|
|
|
|
|
CORPORACAONF wrote:
a control array
Leads me to believe that your using VB6...
CORPORACAONF wrote:
For each tab there is a frame. When you clicks in a tab, it should show the relationed frame.
Why are you using an array of frames? Each frame should go on it's own tab page. When the user clicks the tab, the appropriate tabpage is automatically shown. You don't have to do enything to manage the Visibility of the frames.
Now, if you are switching frames that are not on the tabpages...
Your are setting the Visible property to true, but this doesn't NOT bring the frame to the top of the stack of frame, if they are on top of each other. You must set the Visible property of the frame that is being hidden to False. That way your visible frame will show even though it has other, non-visible frames on top of it.
RageInTheMachine9532
|
|
|
|
|
I am trying to create the add-in for some application and want to get the even
when the active document is closing. How can i get the even when active
document is closing?
Thanks for your help in advance.
Shinya
|
|
|
|
|
Hi, I'm a newbe and need some help. I'm trying to write some code (in vb.net) to get the ntid of the last user to modify a specific file.
Thanks for your help.
|
|
|
|
|
That's easy! NTFS doesn't record such information. There's no way to determine what ID that was.
You can get the last modification time of the file, using the FileInfo class, but not the ID of the person who did it. For one, NTFS doesn't track such information since any number of users can have a file open at the same time. And two, the .NET Framework doesn't yet support the NTFS security system. You'd have to P/Invoke a bunch of Win32 functions and structures to get the security information, like what users are AUTHORIZED to open the file, or what have you.
RageInTheMachine9532
|
|
|
|
|
Thanks for the info. I guess i'll have to figure out something else.
|
|
|
|