Wrox Programmer Forums
|
ASP Pro Code Clinic As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Pro Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 8th, 2003, 09:26 PM
Authorized User
 
Join Date: Jun 2003
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to call C functions in ASP

Hi,
Does anyone know how to call C excutables within asp pages?

Thanks
 
Old June 9th, 2003, 07:18 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 215
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Do you want to call a function or an executable?

To call a C function from within an asp page means that the C code must be compiled into a COM object and that the function must be exposed. I wrote some code that did this once using VC++ 6 and it was a major headache. Either you know the inner workings of COM well, or you let the compiler generate all the code for you (and be prepared to start from the beginning each time you make a nmistake).

To a C execuable is a different kettle of fish. In fact it is just an executable. You can create a WScript object, which basically gives you access to the command line and you can execute any executable from there. I'm not sure about capturing the output, but you would certainly be able to read a text file.

Let me know which of these you want and I can provide more information.

regards
David Cameron
 
Old June 9th, 2003, 08:18 PM
Authorized User
 
Join Date: Jun 2003
Posts: 28
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi David,
thanks for the info.
Sorry about the confusion, I am actually trying to use a C executable in asp.
So if you have any more info in that area, please let me konw.
Also, I'm not too familiar with the WScript and how to go about to create one.
It'd be great if u can provide some sample code or detailed description.

Thanks Again

Allan
 
Old June 9th, 2003, 08:24 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 215
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Code:
Dim wssShell
Dim intRet

Set wshShell = Server.CreateObject("WScript.Shell")

intRet = wshShell.Run("executable goes here", 6, True)

Set wshShell = Nothing
intRet holds the return value from the application (In C normally 0 of everything was OK). I don't know about capturing the printf()/std::cout text.

regards
David Cameron
 
Old June 10th, 2003, 06:42 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,212
Thanks: 0
Thanked 1 Time in 1 Post
Default

If you need to capture stdout then, presumably, you have a C command-line program so you should use the Exec method of the WScript.Shell object, not the Run method. The Exec method returns an object which has properties/methods for capturing stdout.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Howto call VBA functions using Java kotaiah Java Basics 2 June 20th, 2007 10:13 AM
Re: ASP DB/RS functions in ASP.NET spinout ASP.NET 2.0 Basics 7 May 29th, 2007 11:00 AM
Dynamically call javascript functions austinf Javascript 1 May 13th, 2006 07:31 AM
call functions of dll Digon Classic ASP Basics 1 December 13th, 2005 06:12 AM
How to call C# COM overloaded functions from ASP? khaledriyal C# 0 October 11th, 2005 03:13 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.