|
Hi,
I have an web application running on a applicationserver. Now I want to shutdown local software on the client from the browser.
I use asp.net but I realized I needed av VBscript to execute on the local client to be able to get a handle for the local applicaition that I want to shutdown. But how do I use the WINAPI methods sendMessage and findWindow in VBscript. I know I have to import user32.dll.
Im really bad at scripting...)
THANKS!
Ibana
|
|
|
|
|
VBScript, or any script running in a browser for that matter, has absolutely no access to the Win32 Api. It's impossible to do what you want from inside a browser session without the user downloading, installing, and allowing script to execute, a custom COM object that does the same thing.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
thanks for your replay,
Do you have any suggestion how to access the winapi on the local machine from my asp.net/C# application running on a server. I need to use the winapi to shutdown a local installed software.
Should a make a small app that runs on the local machine that calls the winapi? Are there any better solutions?
/ibana
|
|
|
|
|
There is NOTHING in your ASP.NET code that can get to the client machine. It's IMSPOSSIBLE. Your app will have absolutely no permissions onthe local machine.
Also, script running inside a browser session will not have any access to other processes running outside the browser session and has no access to any client hardware or system resources.
The user MUST install a component to do this, and it will ONLY work if security inside the browser is stripped down to nothing! Your web app cannot stop a process outside the browser, period, unless the user turns the security for the zone your code came from down to nothing! This is something that no sane network admin on earth would do!
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I know this is a bit old discussion, but thought of sharing this:
Info/Theory:
~~~~~~~~~~~
User32.dll is the source of many of the most common Windows API's, that allow you to
interact with the operating system at a lower level.
Please check: https://social.msdn.microsoft.com/Forums/windows/en-US/b04153ff-e4fb-4500-a8e4-3a685208af57/when-to-use-user32dll-and-how?forum=winforms
Following is the code to access Win32 API using VBSCript.
---------------------------------------------------------
' --------------- Start of Code ------------------------------------------------------------
Dim excel
Set excel = CreateObject("Excel.Application")
Dim strMacro
strMacro = "CALL('user32', 'MessageBoxA', 'JJCCJ', 0, 'Hello, Win32 API(VBScript) World - My call via User32 dll!', 'Hello, World!', 0)"
strMacro = Replace( strMacro, "'", """" )
excel.ExecuteExcel4Macro( strMacro )
'---------------- End of Code --------------------------------------------------------------
Copy the above to a notepad & save it as : myMessage.vbs and double click it.
Expected Result: Please see the script in action : Windows API VBScript Calling User32 DLL directly - YouTube[^]
|
|
|
|
|
That's cute and all, but it also requires Office be installed on the machine in order to work and that's not going to be the case on every machine.
Frankly, using Excel as an intermediary just to run a single line of code is a very heavy cost and a bit ridiculous.
|
|
|
|
|
This only happens if you have any of the following type of laptops:
a) Mac / MacBook with IoS
b) Laptop used exclusively for non-MS office testing
c) New Laptop with no MS Office Installed
d) Loaner laptop with no MS Office
e) Sometimes if you have had a crash of MS Office on your laptop - then also the Excel Application
will not work - for this.
f) if your enterprise IT has disabled using MS Office COM Objects and/or restricted authorization
to use MS Office COM objects/APIs.
ELSE I do not know of any other reason - any laptop not having MS Office installed.
But the solution does work - and you do not need to use any other tools.
Good luck.
|
|
|
|
|
First, using a heavy weight application, like Excel, to call a couple of Win32 API's is ridiculous.
Also, going back to the original context of the question, the script, running in a browser, can NOT create an instance of Excel. COM-interop is off-limits because of security concerns. It's also the reason ActiveX is no longer supported by browsers.
|
|
|
|
|
Does anyone know a way for me to use a Windows icon that is stored on the Shell32.DLL file? I'm sure there is a Windows API call for this but I can't find it.
For example: If I selected a Drive from the DriveList control I want the icon for the selected drive to show up on the Treeview control as the root node.
Thank you
Quecumber256
|
|
|
|
|
You mean this[^] little article on CP...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
No, I mean using a call to the Shell32.DLL to retrieve a specific icon from their list.
Thank you,
Quecumber256
|
|
|
|
|
You don't!! You use the Extract icon method to get the icons out of the file, just like Shell32 does. Shell32 won't pick the icon for your, but it will tell you what type each drive is. You then have to use that information to pick the icon to show.
What do you need to determine the drive type? Easy! Call the Win32 Api function <a href="http://msdn.microsoft.com/library/en-us/fileio/fs/getdrivetype.asp?frame=true" rel="nofollow">GetDriveType</a>[<a href="http://msdn.microsoft.com/library/en-us/fileio/fs/getdrivetype.asp?frame=true" target="_blank" rel="nofollow" title="New Window">^</a>] , or <a href="http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/reference/functions/RealDriveType.asp?frame=true" rel="nofollow">RealDriveType</a>[<a href="http://msdn.microsoft.com/library/en-us/shellcc/platform/shell/reference/functions/RealDriveType.asp?frame=true" target="_blank" rel="nofollow" title="New Window">^</a>] .
You can find the P/Invoke Declares on P/Invoke.net if you have trouble figuring it out, or you could just ask...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-- modified at 21:29 Saturday 11th February, 2006
|
|
|
|
|
Hello
my english is not good; escuse me for that.
I'd like to know how can I import my phonebook from outlook express to my database; I'm using ms access 2003 and VBA.
thanks
|
|
|
|
|
Without getting into the overly-convoluted and gory details of calling the Win32 Api functions to export the address book...
Go into Outlook Express, click the File menu, Export, and export the address book to a Text (CSV) file. You can the easily go into Access and import the data from that file.
But, if you must do this in code, there is only one place to get the API documention anymore, here[^].
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
I am unable to set parameter to crystal report. Report source is SQL Server Stored Procedure. Please help me.
|
|
|
|
|
Is there any grid control in vs 2003 along with DataGrid. I want to use DataGridView in VS2003
|
|
|
|
|
Can't do it. Visual Studio 2003 will NOT use the classes in the .NET Framework 2.0. You'll have to use VB.NET 2005 to use that control.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hellow ..
i am doing reports in the crystal ...
i need to run them on differnt databases , but when i do the report i bind them to the DB server in my computer ...
then when i run it on other computers it ask for logon information beacause the server name there is defrent but the same tabels .
i know there is a databaselogon command in the vb.net , but it is not working for me ..
anyone have suggestion or can offer a sample code ?
thxx
|
|
|
|
|
Try This . But This is not the best way. But u don't have no other way. Try it.
Dim tbCurrent As CrystalDecisions.CrystalReports.Engine.Table
Dim tliCurrent As CrystalDecisions.Shared.TableLogOnInfo
' Create a report document instance to hold the report
Dim rptStudent As New ReportDocument
Try
' Load the report
rptStudent.Load("D:\sample_project\report\rptlist.rpt")
' Set the connection information for all the tables used in the report
For Each tbCurrent In rptStudent.Database.Tables
tliCurrent = tbCurrent.LogOnInfo
With tliCurrent.ConnectionInfo
.ServerName = "ServerName"
.UserID = "username"
.Password = "pws"
.DatabaseName = "DBName"
End With
tbCurrent.ApplyLogOnInfo(tliCurrent)
Next tbCurrent
' Set the report source for the crystal reports
' viewer to the report instance.
frmrpt.crptdate.ReportSource = rptStudent
' Where I put the selection formula
frmrpt.crptdate.SelectionFormula = selectionstr
' Zoom viewer to fit to the whole page so the user can see the report
frmrpt.crptdate.Zoom(2)
Catch Exp As LoadSaveReportException
MsgBox("Incorrect path for loading report.", _
MsgBoxStyle.Critical, "Load Report Error")
Catch Exp As Exception
MsgBox(Exp.Message, MsgBoxStyle.Critical, "General Error")
End Try
!alien!
|
|
|
|
|
wow , alien that's great ...
u just saved my life
yesterday i been around the net for 6h , looking for the answer , and didn't find , and in 2 lines u had solve my problems
|
|
|
|
|
i m trying to use local keyboard layout file which contain local input method's.
i have a problem to use and/or call .KBD [keyboard layout file]in visual basic 6
Pleae help me
Please Help Me.
justzain
|
|
|
|
|
You don't read or call a ".KBD" File, and as far as I know, they can be used only in win9x. (NT uses .DLL files.)
There is an example on a link at the bottom of this page.
(It assumes you have already put in the registry entries, where windows expects them.)
http://mentalis.org/apilist/LoadKeyboardLayout.shtml[^]
progload
|
|
|
|
|
I'm trying to make a new windows form through a timer elapsed event
one form runs the timer that trigger the event and pops another form
BUG: the poping form will not shou form elements like buttons or labels
does anyone know what I am doing wrong??? (code bellow)
'''create timer instance
Private t As New System.Timers.Timer(2000)
Private Sub Form1_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
'''handler call TimerFired bellow
AddHandler t.Elapsed, AddressOf TimerFired
End Sub
Public Sub TimerFired(ByVal sender As Object, _
ByVal e As System.Timers.ElapsedEventArgs)
''creates anew instance of the second form
Dim form2 As New Form2
''when it show, the canvas is ok, but the elements are like a missing hole
form2.Show()
t.Enabled = False
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
t.Enabled = True
End Sub
End Class
AM I INSTANTIATING OT DECLARING SOMETHING WRONG?
|
|
|
|
|
The problem is you're using the wrong Timer. The callback from the Timer is run on a seperate thread, therefor, you're creating your new form on a seperate thread which will have no access to the app's message pump. The form, and it's controls, will not properly receive the WM_PAINT message.
Keep the Form creation on the UI thread (the same thread your StartUp form is created on). Use the Form's Timer control instead. This will fire an event on the same thread as the UI and let you create the new form on that same thread.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
thanks dude, it did work with the form timer
|
|
|
|