Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old July 26th, 2005, 12:17 PM
IsaacSchlueter IsaacSchlueter is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 8 IsaacSchlueter User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 sec
Reputation Power: 0
Question Issues Calling EXE from within VB6 DLL

I have a DLL that searches a database for user input. However, our users can't spell, and this seriously messes up the search results. We need a spellchecker to suggest better search terms.


Option 1: Roll My Own
This really isn't an option. Writing a spellchecker is the biggest example of re-inventing the wheel that I can think of, and it's a highly non-trivial task.
No way, Jose.


Option 2: MS Word
There are a lot of sites that say that you can use Winword to spellcheck stuff from within an ASP or DLL application.
The problem is, you have to jump through a bunch of hoops to get it to work, and even when it DOES work, it's very delicate and easy to crash. If you're not lucky and super-careful, you end up with 100 instances of WINWORD.EXE taking up all of your server's resources.
Scratch that.


Option 3: Commandline External EXE
I found ASpell.exe, which really seems to be the ticket. It's a command-line utility that can take piped input and output the spell-checked data to a txt file. See http://aspell.sourceforge.net/ for more information.

The format of the command is this:
Code:
C:\Path\To\echo "missspeled serch turmz" | aspell.exe -a > C:\Path\To\output.txt


This works fine when running interpretively (of course ), and it also works on a Windows 2000 test server running compiled. However, when running on our live server, this happens:
1. The spelling check runs, and doesn't seem to have any errors, but the output never goes to the txt file.
2. Once this has been done even once, the server fails on the next call to read data from the database, with this error:
Code:
-2147418105
Automation error
The callee (server [not server application]) is not available and disappeared; all connections are invalid.
The call may have executed.

3. Requests for other pages start taking enormously long amounts of time to complete.

Here's the basics of how I'm calling the EXE in my DLL:
1. Created a batch file that contains this:
Code:
echo %1 | c:\path\to\aspell.exe -a > outfile.txt

2. In MyClass.SpellCheck(strQ), do this:
Code:
    PID = Shell("c:\path\to\spellcheck.bat """ & strQ & """", vbHide)
    If PID = 0 Then Exit Function
    
    hPID = OpenProcess(&H400, False, PID) 
    Do
        GetExitCodeProcess hPID, lngExitCode
        DoEvents
    Loop While lngExitCode = &H103
    Call CloseHandle(hPID)
Any ideas?

Reply With Quote
  #2  
Old July 26th, 2005, 01:33 PM
IsaacSchlueter IsaacSchlueter is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 8 IsaacSchlueter User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 34 sec
Reputation Power: 0
Ok, did some more research, and here's the problem:

"ASpell -a" allows you to use the program in "pipe" mode. That means, if you pipe your output into aspell.exe with the -a switch, then it'll spit back the results. You can then pipe the results of THAT program into a txt file, with the > command-line operator.

However, if you do "echo "sum badlee speeled werds" | aspell -a > output.txt", then you're REALLY calling CMD.exe! So, that means that you need to give your IUSR_MachineName execute access to cmd.exe.

This strikes me as really really really Super-Insecure, since all we're really needing to do is spit out a few words onto the console. Is there a better way to put something onto the console? Perhaps is there an "echo.exe" program, that functions just like the DOS Echo command? I would happily give IUSR_MachineName access to that rather than allow it to touch CMD.exe, potentially allowing someone to "CMD /C format C:" or something equally devastating.

Reply With Quote
  #3  
Old July 27th, 2005, 12:05 AM
Doug G Doug G is offline
Grumpier Old Moderator
ASP Free God 11th Plane (10000 - 10499 posts)
 
Join Date: Sep 2003
Posts: 10,143 Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level)Doug G User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 3 Weeks 4 Days 23 h 29 m 58 sec
Reputation Power: 181
My guess is there is a COM spelling checker out there somewhere so you don't need to mess with cmd.exe permissions.

You might take a look at using the wscript object which lets you run command line programs. Also it can be a problem capturing console output text from code.
__________________
======
Doug G
======
I didn't attend the funeral, but I sent a nice letter saying I approved of it. --Mark Twain

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > Issues Calling EXE from within VB6 DLL


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT