Advertisement
C_Volume2 Registry #83969

Run Program On Startup (Registry)

Places your program in the Windows Registry so it will run at startup.

AI

Riepilogo AI: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Codice sorgente
original-source
// Place registry in your USES
uses
 Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, registry, StdCtrls;

// This is the procedure (False means remove, True means create)
procedure RunOnStartup(sProgTitle, sCmdLine: string; bStartup: boolean );
var
 sKey: string;
 reg : TRegIniFile;
begin
 sKey := ''; //sKey := 'Once' if you wish it to only run on the next time you startup.
 if bStartup = false then //If value passed is false, then value deleted from Registry.
 begin
 try
 reg := TRegIniFile.Create( '' );
 reg.RootKey := HKEY_LOCAL_MACHINE;
 reg.DeleteKey(
  'Software\Microsoft'
  + '\Windows\CurrentVersion\Run'
  + sKey + #0,
  sProgTitle);
 reg.Free;
 exit;
 except //Using Try Except so that if value can not be placed in registry, it
 //will not give and error.
 end;
end;
try
 reg := TRegIniFile.Create( '' );
 reg.RootKey := HKEY_LOCAL_MACHINE;
 reg.WriteString(
  'Software\Microsoft'
  + '\Windows\CurrentVersion\Run'
  + sKey + #0,
  sProgTitle,
  sCmdLine );
 reg.Free;
 except
 end;
 end;
<?
if($username && $password) {
 mysql_connect() or die ("Whoops");
 $password = md5($password);
 $sql = "select * from login where username='$username'";
 $r = mysql_db_query("reg_users",$sql);
 if(!mysql_num_rows($r)) {
  header("Location: $SCRIPT_NAME");
 }
 $user = mysql_fetch_array($r);
 if($user["password"] == $password) {
  $password = serialize($password);
  setcookie("login_cookie","$username $password");
  $msg = "<meta http-equiv=\"Refresh\" content=\"0;url=./mainpage.php\">";
 }else{
   header("Location: $SCRIPT_NAME");
 }
}
if($msg) echo $msg;
?>
<html>
<title>Login to PHP Coders DB</title>
<body bgcolor="yellow" text="black">
<form method="post" action="<?echo $SCRIPT_NAME;?>">
<center><font size=+5><b>Welcome!</b></font></center>
<br>
<br>
<br>
<table cellspacing=0 cellpadding=0 width=320 align="center">
<tr><td>
Username:
</td><td>
<input name="username" type="text" width=10>
</td></tr>
<tr><td>
Password:
</td><td>
<input name="password" type="password" width=10>
</td></tr>
<tr><td colspan=2 align="center">
<input name="login" type="submit">
</td></tr>
</table>
</form>
</html>
<? /* Here is that include file code */ ?>
<?
if(!$login_cookie)
 header("Location: ./login.php");
if($phpcoders) {
 mysql_connect() or die ("Whoops");
 $user = explode(" ","$login_cookie");
 $sql = "select * from login where username='$user[0]'";
 $r = mysql_db_query("reg_users",$sql);
 if(!mysql_num_rows($r)) {
  header("Location: ./login.php");
  mysql_free_result($r);
 }
 $chkusr = mysql_fetch_array($r);
 mysql_free_result($r);
 if(unserialize($user[1]) != $chkusr[1])
  header("Location: ./login.php");
}
?>

Upload
Commenti originali (3)
Recuperato da Wayback Machine