# FILE: src-board-subs-win32
#-------------------------------------------------------------------------------
# DISCUS VERSION 3.10 COPYRIGHT NOTICE
#
# Discus 3.10 is copyright (c) 2000 by DiscusWare, LLC, all rights reserved.
# The use of Discus is governed by the Discus License Agreement which is
# available from the Discus WWW site at:
#    http://www.discusware.com/discus/license
#
# Pursuant to the Discus License Agreement, this copyright notice may not be
# removed or altered in any way.
#-------------------------------------------------------------------------------

sub Win32_send {
	my ($mail_prog, $cmdline, $cwd, $showheaders) = @_;
	if ($showheaders) {
		&header;
		print "<HTML><HEAD><TITLE>Header Result</TITLE></HEAD>\n";
		print "<BODY BGCOLOR=#ffffff TEXT=#000000>$fs";
		print "<CENTER><FONT SIZE=3><B>Debugging Information for Win32::Process Call</B></FONT></CENTER>\n";
		print "<HR>\n";
		print "</FONT><PRE>\n";
		print "<B>Mail Program:</B>           $mail_prog\n";
		print "<B>Command Line Arguments:</B> $cmdline\n";
		print "<B>Working Directory:</B>      $cwd\n";
		print "<FONT COLOR=#ff0000>Starting Win32::Process</FONT>\n";
	}
	use Win32::Process;
	use Win32;
	if ($showheaders) {
		print "<FONT COLOR=#00aa00>Win32::Process Started</FONT>\n";
		print "<FONT COLOR=#ff0000>Creating Process</FONT>\n";
		print "<I>Here is where you may see useful information as to why your mailing is not\n";
		print "working as you desire.  If you see absolutely nothing here until the exit code,\n";
		print "you should turn off 'quiet' mode (remove -q from command line options for BLAT) or\n";
		print "turn on verbose mode.  Good luck!</I>\n\n";
		print "<FONT COLOR=#0000ff>";
	}
	if (Win32::Process::Create($ProcessObj, "$mail_prog", "$cmdline", 0, DETACHED_PROCESS, $cwd)) {
		$ProcessObj->Wait(INFINITE);
		$ProcessObj->GetExitCode( $ExitCode );
		if ($showheaders) {
			print "\n</FONT><FONT COLOR=#00aa00>Process Exit Code <B>$ExitCode</B></FONT>\n";
			if ($ExitCode == 0) {
				print "<FONT COLOR=#00aa00>This means <B>Success!</B> Congratulations!</FONT>\n";
				print "If this mail message didn't go through, it's because the recipient e-mail\n";
				print "account is not functioning properly, or it has a spam filter installed that\n";
				print "is blocking this message.\n";
				return 0;
			} else {
				print "<FONT COLOR=#ff0000>This means <B>Failure!</B> Sorry!</FONT>\n";
				print "</PRE><P><HR><FORM><CENTER><INPUT TYPE=BUTTON onClick=\"history.back()\" VALUE=\"Go Back\"></CENTER></FORM>\n";
				print "</BODY></HTML>\n";
				return -1;
			}
		}
		return $ExitCode;
	} else {
		&error_message("Windows Process Creation Error", Win32::FormatMessage(Win32::GetLastError()) . "<P>Command line:<PRE>$cmdline</PRE><P>CWD:<PRE>$cwd</PRE>") if !$showheaders;
		print "<B>Process Creation Error</B>: ", Win32::FormatMessage(Win32::GetLastError());
		print "</BODY></HTML>\n";
		exit(0);
	}
}

1;

# END - FILE IS CORRECTLY UPLOADED #
