The method always works fine on Windows XP, but does not work on Windows
2000 Professional with SP4+IE6SP1 or Windows 2000 Server with SP4+IE6 SP1
After adding some debug code to the ActiveX DLL code, I found that
mlngINet=13369348 after the call to InternetOpen(mstrAgentName,
INTERNET_OPEN_TYPE_DIRECT, vbNullString, vbNullString, 0)
'InternetOpen
Private Declare Function InternetOpen Lib "wininet.dll" Alias
"InternetOpenA" _
(ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As
String, _
ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
However, call to mlngINetConn = InternetConnect(mlngINet, mstrServerName, _
INTERNET_INVALID_PORT_NUMBER, mstrUserID, mstrPassword,
_
INTERNET_SERVICE_FTP, lngFlags, 0)
returns 0 there are no error descriptions returned!!
Why is this it works so fine in WinXP and not on Win2K? I did regsvr32 the
dll I compiled on the Win2K machines.
How could I get around the problem?? Would I have to *compile* and not just
regsvr32 the DLL on the Win2K server?? I would rather not have to install
Visual Studio on a server !!
I checked that the wininet.dll on Both machines are of version
6.0.2800.1106, although on WinXP, there is an additional file property
(under the version tab): File Version- 6.00.2800.1106 (xpsp1.020828-1920),
all other properties are identical!
> How could I get around the problem?? Would I have to *compile* and not just
> regsvr32 the DLL on the Win2K server?? I would rather not have to install
> Visual Studio on a server !!
I can't say for sure if it will affect your current problems at all,
but I ALWAYS HIGHLY recommend running ALL your production compiles
on the OLDEST platform you intend to support.
Yeah, it's a pain, but I keep one box running Win95b to this day,
and believe me it's saved me (and my clients) hundreds of hours
just to not fight those issues (mostly DLL Hell) which it does solve.
You shouldn't need to install VS on the server; any W2K box, even Pro,
with the same (or older) revision level (SPs and IE) should do okay.
Bob
--
VB expert looking for work <http://obob.com/bob/resume/>
Might you have a firewall on the Win2k machine?
Calling entry points in the wininet DLL on a server is not recommended. Much
has been written about it. A large part of the XML Parser code was written
to deal with these issues.
If you have never used objects from the XML 4.0 SDK, try this one:
Msxml2.ServerXMLHTTP.4.0
Furthermore, troubleshooting an object that is making HTTP and FTP
connections is very advanced, requiring a wide variety of tools.
Ideally you should be examining the request-response-challenge
headers in some test cases on both machines. To troubleshoot server
scripts, I use the HttpSniffer.pl by Tim Meadowcroft.
It runs a proxy pass-through that logs all HTTP headers.
See:
http://www.schmerg.com/code.asp
(requires a Perl interpreter to be installed)
hth,
Mark Pryor
In your VB component that call InternetConnect that returns 0, you need to
get the specific WinINet error code as documented in:
InternetConnect
http://msdn.microsoft.com/library/en-us/wininet/wininet/internetconnect.asp
If null is returned, the docs say to call GetLastError in that case...
GetLastError
http://msdn.microsoft.com/library/en-us/debug/base/getlasterror.asp
which in turn says for VB to use Err.LastDLLError
LastDLLError Property
http://msdn.microsoft.com/library/en-us/vbenlr98/html/vaprolastdllerror.asp
Error Messages (Windows Internet (WinINet): Platform SDK)
http://msdn.microsoft.com/library/en-us/wininet/wininet/wininet_errors.asp
All of the ERROR_INTERNET_* errors are defined in WinINet.h.
Source for: WinINet.h
http://msdn.microsoft.com/downloads/samples/internet/ShowSource.asp?Filename=/downloads/samples/internet/libraries/ie5_lib/Include/WinINet.h
--
Michael Harris
Microsoft.MVP.Scripting
Microsoft® Windows®2000 Scripting Guide
http://www.microsoft.com/technet/scriptcenter/scrguide/sagsas_overview.asp
TechNet Script Center Sample Scripts
http://www.microsoft.com/technet/scriptcenter/default.asp
Download in HTML Help format (searchable and indexed)
http://www.microsoft.com/downloads/release.asp?ReleaseID=38942
WSH 5.6 documentation download
http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9&displaylang=en
But how could I do that with FTP?? (e.g. I need to specify the remote file
name as well, etc.)?
"Mark_Pryor" <marks.pr...@SHRUBverizon.net> wrote in message
news:ugdv8iq...@TK2MSFTNGP11.phx.gbl...
This is regardless of whether I pass in a server name that is an IP address
or a hostname which I could both manually ping and do a FTP from the command
prompt. Very confused why that is the case on Win2k!!
If you are in a hurry to get a script working using an existing object
try this WinInet wrapper written by Karl Peterson (pure VB):
http://www.mvps.org/vb/code/
look for vbInet.zip
Making an FTP upload using vbInet is easy. This code has been in
use for 3 years now: I get my password from
the registry (rot13'd)
----- begin UpFTP.wsf -------------
<job>
<script language="JScript">
/* sub main */
function OldRot13(s){
/*
keywords="rot13 encrypt twistr twister function jscript"
*/
var sResult = "";
var i = 0;
var d = 0;
// Check every character in the string
for (i = 0; i < s.length; i++) {
// Get the next character
d = s.charCodeAt(i);
// Is it an upper-case character?
if ((d >= 65) && (d <= 90)) {
// Increment it
d += 13; // Rotate any over-flows
if (d > 90) {
d = 64 + (d - 90);
}
}
// Is it a lower case char?
if ((d >= 97) && (d <= 122)) {
// Increment it
d += 13; // Rotate any over-flows
if (d > 122) {
d = 96 + (d - 122);
}
}
// Add the character to the string
sResult += String.fromCharCode(d);
}
// Return the result
return sResult;
}
</script>
<SCRIPT LANGUAGE="VBScript">
' Script to use the VBInet ActiveX Server
' keywords=" upload WinInet Inet xftp Query HTTP"
' Date="06/28/00"
' ActiveXSite="http://www.mvps.org/vb/code/vbInet.zip"
'
Option Explicit
'On error resume next
'
'
dim oInet, oFso, m_Done
set oArg = WScript.arguments
if oArg.count = 0 then
wscript.echo " this is a drag and drop script "
script_exit
end if
' Define the Upload object and the callback Namespace
set oInet = WScript.CreateObject("VBInet.CNetUpload","oInet_")
' the ubiquitous File object
set oFso = WScript.CreateObject("Scripting.FileSystemObject")
dim sMyKey, MyPw, oArg, sFname, sCurFile
'==============================
' Get your password anyway that you like
sMyKey = "HKCU\Software\IDM Comp\U\"
dim MyWF, WSHShell
set WSHShell = CreateObject("WScript.Shell")
if Err then
pout("objerr=" & err.description)
err.clear
script_exit
end if
MyWF = WSHShell.regread(sMyKey & "wfbyext\")
' jscript helper function
MyPw = Mid(OldRot13(MyWF),3)
'
'====================================
if err then pout("error=" & err.description)
err.clear
oInet.Server = "ftp-www.joehacker.com"
oInet.UserName = MyUser
oInet.Password = MyPw
oInet.RemotePath="/your_root"
oInet.Binary = vbTrue
oInet.ShowProgress = vbtrue
dim lSuc, tLim, tTemp
' loop over all dropped files
for each sCurFile in oArg
oInet.LocalFile = sCurFile
oInet.RemoteFile = oFso.Getbasename(sCurFile) & "." & _
oFso.GetExtensionName( sCurFile)
pout("Ready to transfer " & sCurFile)
lSuc = oInet.BeginTransfer
m_Done = vbFalse
' sleep the loop until oInet triggers the callback
Do Until (m_Done OR ( oInet.Busy= vbFalse))
' limit to 15 seconds or higher for large files
'
WScript.Sleep( 100)
'
Loop
if err then
pout("Error=" & err.description)
else
pout( "BytesWritten=" & oInet.BytesWritten & "/" & oInet.BytesTotal)
'WScript.Sleep(1000)
end if
next
' pause to allow user to read results of upload
WScript.sleep 3000
pout("exiting script")
script_exit
function pout(Str)
WScript.echo(Str)
end function
' callback interface
sub oInet_TransferComplete()
m_Done = true
pout("Success ++FTP is done")
end sub
sub script_exit()
if IsObject(oInet) then
set oInet = nothing
set oFso = nothing
set WSHShell = nothing
end if
WScript.quit(0)
end sub
</script>
</job>
------ end script ---------
>
> "Mark_Pryor" <marks.pr...@SHRUBverizon.net> wrote in message
> news:ugdv8iq...@TK2MSFTNGP11.phx.gbl...
> > Hello,
> > "Patrick" <pa...@reply.newsgroup.msn.com> wrote in message
> > news:eo8MkHq4...@TK2MSFTNGP09.phx.gbl...
> > > I have followed the guidelines at
> > http://www.15seconds.com/issue/981203.htm
> > > and created an ActiveX DLL (using Visual Basic 6.0 Enterprise Edition
> with
> >
"Patrick" <pa...@reply.newsgroup.msn.com> wrote in message
news:%23bD0CJt...@TK2MSFTNGP11.phx.gbl...
"Bonj" <a...@b.com> wrote in message
news:%23JwjgUu...@TK2MSFTNGP09.phx.gbl...
another DLL wrapper works, but the following doesn't work!
http://www.15seconds.com/issue/981203.htm (returns error -12007 to indicate
it can't find the Internet Server, although I could manaully do a FTP on the
command prompt, on Win2K Server or workstation)
http://www.serverobjects.com/comp/AspInet.zip (the putfile method fails, and
the error code returned is 0, so no clues where it failed)
"Mark_Pryor" <marks.pr...@SHRUBverizon.net> wrote in message
news:O$nYzJu4D...@TK2MSFTNGP09.phx.gbl...
Thanks for post in the community.
I am researching the issue. I will update you with new information ASAP.
Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
I found out why my code isn't workingg on Win2K- i introduced a typo in the
sServerName property!
What is wrong with callingg entry points in the wininet DLL on a server? I
see no other way of doing a FTP *upload* on a Win2K server (other than doing
a very ugly ftp -i -s:c:\uglycommand.txt, which could hardly have any error
handling!)
It's a shame Wininet.dll doesn't seem to ever return any error message, but
the error code is useful enough.
"Mark_Pryor" <marks.pr...@SHRUBverizon.net> wrote in message >
Apparently they are there, but I can't get google or the msdn search engine
to find them for me.
tiafah, jw
"Michael Harris (MVP)" <mikhar at mvps dot org> wrote in message
news:OdBek%23s4DH...@TK2MSFTNGP12.phx.gbl...
Greetings, jaWar (where ya' been hidin' <g> ?)
The WinINet.h link was apparently part of some online sample. I don't think
individual PDSK files are typically accessible over the web...
You can order the entire platform SDK on CD for about $10 US from:
https://qmedia.e-storefront.com/showcontent.asp?contentname=PlatformSDKHome
and I assume you already know about selective PSDK downloads from:
SDK Update - Home
http://www.microsoft.com/msdownload/platformsdk/sdkupdate/home.htm
>
> "Michael Harris (MVP)" <mikhar at mvps dot org> wrote in message
> news:OdBek%23s4DH...@TK2MSFTNGP12.phx.gbl...
>>
>> Source for: WinINet.h
>>
>
http://msdn.microsoft.com/downloads/samples/internet/ShowSource.asp?Filename=/downloads/samples/internet/libraries/ie5_lib/Include/WinINet.h
>>
>> --
>> Michael Harris
>> Microsoft.MVP.Scripting
--
I cam glad you have found out why your code did not work.
Based on my test, the two dll you refer to ago will also work on my pc.(I
test on Windows 2000 server)
http://www.15seconds.com/issue/981203.htm
http://www.serverobjects.com/comp/AspInet.zip
Here is my test script.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<BODY>
<%
dim oftp, sfilename
Err.Clear
sfilename = "c:\test7.html"
'--------------------------------------------------------------
set oftp = Server.CreateObject("NIBLACK.ASPFTP")
if oftp.bQGetFile("sha-vphuang-xp", "anonymous", "a@a.c", "test.html",
sfilename, 1, True) then
Response.Write "Getfile successfully" & vbCrlf
End if
If oftp.bQPutFile("sha-vphuang-xp", "anonymous", "wa...@wallyworld.com",
"c:\test.html", "dirmap.txt", TRANSFER_TYPE_ASCII) Then
Response.Write "Putfile successfully" & vbCrlf
End if
Set oftp = nothing
if err.number <> 0 then
Response.Write Err.Number & " " & Err.Description
end if
'--------------------------------------------------------------
dim oAspInet
set oAspInet = Server.CreateObject("AspInet.FTP")
If oAspInet.FTPPutFile("sha-vphuang-xp", "anonymous", "us...@hostname.net",
"fdfd.html", "c:\test.html", 1) Then
Response.Write "Putfile successfully" & vbCrlf
End if
set oAspInet = nothing
if err.number <> 0 then
Response.Write Err.Number & " " & Err.Description
end if
%>
</BODY>
</HTML>
>What is wrong with callingg entry points in the wininet DLL on a server? I
>see no other way of doing a FTP *upload* on a Win2K server (other than
doing
>a very ugly ftp -i -s:c:\uglycommand.txt, which could hardly have any error
>handling!)
So I am confused that why you think you can do FTP upload only by the ftp
command?
If you have any concern on this issue, please post here.
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
"Peter Huang" <v-ph...@online.microsoft.com> wrote in message
news:tKWmLfM5...@cpmsftngxa07.phx.gbl...
Thanks for the tip. As it is, my best source of "header" files is from an
api-oriented DELPHI site (gasp!). They are a bit out of date, but so am I
(still using win98se).
You may not have seen any recent postings here by me, but I have been
lurking about -- always hoping to learn something. However, there are just
too many highly-qualified experts making valuable contributions for me to
compete in that arena.
As for the rest of it, I continue with my life's work, i.e., coding up those
notoriously unreliable and untrustworthy third-party controls (ugh!).
cheers, jw
++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ jawar productions -- your source for the ultimate
+ in unreliable and untrustworthy (scripting) code.
+ http://home.att.net/~wshvbs/index.htm
++++++++++++++++++++++++++++++++++++++++++++++++++++++