tag:blogger.com,1999:blog-2039341943853525542024-02-20T10:59:50.350-08:00Script SenseScript Collections : Visual Basic, Delphi, C++, Javascript, PHP, Ajax, ActiveX, Components, Sample, Full Application with Source Code, Tips Trick, all for freeaipdamhttp://www.blogger.com/profile/16814089306435554497noreply@blogger.comBlogger22125tag:blogger.com,1999:blog-203934194385352554.post-38468427260302658722010-03-03T20:43:00.000-08:002010-03-03T20:44:43.095-08:00Benchmark or time scriptHere is a little example of how to benchmark or time something with php<br /><br /><div class='code'><br /><?php<br /><br />// a function to get microtime<br />function getmicrotime(){<br /> list($usec, $sec) = explode(" ",microtime());<br /> return ((float)$usec + (float)$sec);<br />}<br /><br />// start time<br />$time_start = getmicrotime();<br /><br />// a little loop to time<br />for ($i=0; $i < 10000; $i++)<br />{<br />// print the loop number<br />echo $i.'<br />';<br />}<br /><br />// the end time<br />$time_end = getmicrotime();<br /><br />// subtract the start time from the end time to get the time taken<br />$time = $time_end - $time_start;<br /><br /><br />// echo a little message<br />echo '<br />Script ran for ' . round($time,2) .' seconds.';<br /><br />?><br /><br /></div><br /><br />This will produce a list of numbers from 0 to 9999 in your browser and tell you how long it took too complete the iterations.aipdamhttp://www.blogger.com/profile/16814089306435554497noreply@blogger.com2tag:blogger.com,1999:blog-203934194385352554.post-26280230499910423822010-03-03T20:36:00.000-08:002010-03-03T20:41:31.181-08:00PHP Function Number to Roman and Roman to Number<div class="code"><br />class konversi{<br /> function roman2number($roman){<br /> $conv = array(<br /> array("letter" => 'I', "number" => 1),<br /> array("letter" => 'V', "number" => 5),<br /> array("letter" => 'X', "number" => 10),<br /> array("letter" => 'L', "number" => 50),<br /> array("letter" => 'C', "number" => 100),<br /> array("letter" => 'D', "number" => 500),<br /> array("letter" => 'M', "number" => 1000),<br /> array("letter" => 0, "number" => 0)<br /> );<br /> $arabic = 0;<br /> $state = 0;<br /> $sidx = 0;<br /> $len = strlen($roman);<br /><br /> while ($len >= 0) {<br /> $i = 0;<br /> $sidx = $len;<br /><br /> while ($conv[$i]['number'] > 0) {<br /> if (strtoupper($roman[$sidx]) == $conv[$i]['letter']) {<br /> if ($state > $conv[$i]['number']) {<br /> $arabic -= $conv[$i]['number'];<br /> } else {<br /> $arabic += $conv[$i]['number'];<br /> $state = $conv[$i]['number'];<br /> }<br /> }<br /> $i++;<br /> }<br /><br /> $len--;<br /> }<br /><br /> return($arabic);<br /> }<br /><br /><br /> function number2roman($num,$isUpper=true) {<br /> $n = intval($num);<br /> $res = '';<br /><br /> /*** roman_numerals array ***/<br /> $roman_numerals = array(<br /> 'M' => 1000,<br /> 'CM' => 900,<br /> 'D' => 500,<br /> 'CD' => 400,<br /> 'C' => 100,<br /> 'XC' => 90,<br /> 'L' => 50,<br /> 'XL' => 40,<br /> 'X' => 10,<br /> 'IX' => 9,<br /> 'V' => 5,<br /> 'IV' => 4,<br /> 'I' => 1);<br /><br /> foreach ($roman_numerals as $roman => $number)<br /> {<br /> /*** divide to get matches ***/<br /> $matches = intval($n / $number);<br /><br /> /*** assign the roman char * $matches ***/<br /> $res .= str_repeat($roman, $matches);<br /><br /> /*** substract from the number ***/<br /> $n = $n % $number;<br /> }<br /><br /> /*** return the res ***/<br /> if($isUpper) return $res;<br /> else return strtolower($res);<br /> }<br />}<br /></div>aipdamhttp://www.blogger.com/profile/16814089306435554497noreply@blogger.com0tag:blogger.com,1999:blog-203934194385352554.post-79168001359067446412010-03-03T20:27:00.000-08:002010-03-03T20:35:25.663-08:00PHP Substr In ArrayTo find if a value exists in an array, the PHP in_array() function works quite nicely. But there are times when only a partial match is required to check in the array. This substr_in_array() function checks will search the values of an array for a substring. The $needl can be a string or an array of strings to search for.<br /><br /><div class="code"><br /><?php<br />/**<br />*<br />* @Search for substring in an array<br />*<br />* @param string $neele<br />*<br />* @param mixed $haystack<br />*<br />* @return bool<br />*<br />*/<br />function substr_in_array($needle, $haystack)<br />{<br /> /*** cast to array ***/<br /> $needle = (array) $needle;<br /><br /> /*** map with preg_quote ***/<br /> $needle = array_map('preg_quote', $needle);<br /><br /> /*** loop of the array to get the search pattern ***/<br /> foreach ($needle as $pattern)<br /> {<br /> if (count(preg_grep("/$pattern/", $haystack)) > 0)<br /> return true;<br /> }<br /> /*** if it is not found ***/<br /> return false;<br />}<br />?><br /></div><br /><br /><span style="font-weight: bold;">Example Usage</span><br /><br /><div class="code"><br /><?php<br /><br />/*** an arrray to search through ***/<br />$array = array('dingo', 'wombat', 'kangaroo', 'platypus');<br /><br /><br />/*** an array of values to search for ***/<br />$strings = array('foo', 'bar', 'kang');<br /><br />/*** check for true or false with ternary ***/<br />echo substr_in_array( $strings, $array ) ? 'found' : 'not found';<br /><br />/*** a single string to search for ***/<br />$string = 'plat';<br /><br />/*** check for true or false with ternary ***/<br />echo substr_in_array( $string, $array ) ? 'found' : 'not found';<br />?><br /></div>aipdamhttp://www.blogger.com/profile/16814089306435554497noreply@blogger.com2tag:blogger.com,1999:blog-203934194385352554.post-41457836461591063282010-03-01T19:35:00.000-08:002010-03-01T19:52:27.739-08:00The Complete Reference for Any jQuery DeveloperTo make optimal use of jQuery, it's good to keep in mind the breadth of capabilities it provides. You can add dynamic, interactive elements to your sites with reduced development time using jQuery. If you are looking for a comprehensive reference guide to this popular JavaScript library, this book is for you.<br /><br />Revised and updated for version 1.4 of jQuery, this book offers an organized menu of every jQuery method, function, and selector. Each method and function is introduced with a summary of its syntax and a list of its parameters and return value, followed by a discussion, with examples where applicable, to assist in getting the most out of jQuery and avoiding the pitfalls commonly associated with JavaScript and other client-side languages.<br /><br />In this book you will be provided information about the latest features of jQuery that include Sizzle Selector, Native event delegation, Event triggering, DOM manipulation, and many more. You won't be confined to built-in functionality, you'll be able to examine jQuery's plug-in architecture and we discuss both how to use plug-ins and how to write your own. If you're already familiar with JavaScript programming, this book will help you dive right into advanced jQuery concepts. You'll be able to experiment on your own, trusting the pages of this book to provide information on the intricacies of the library, where and when you need it.<br /><br />Download :<br />- <a href="javascript:download('http://www.ziddu.com/download/8793563/jQueryandjQueryUIReference1.2.chm.html')">jQuery and jQuery UI Reference 1.2.chm</a><br />- <a href="javascript:download('http://www.ziddu.com/download/8793477/jquery-1.4.chm.html')">jquery-1.4.chm</a><br />- <a href="javascript:download('http://www.ziddu.com/download/8793476/jquery-api-20090115.chm.html')">jquery-api-20090115.chm</a><br /><br />jQuery Resources :<br />- <a href="http://jquery.com/">Jquery.com</a><br />- <a href="http://docs.jquery.com/Downloading_jQuery">Downloading jQuery</a><br />- <a href="http://api.jquery.com/">jQuery Documentation</a><br />- <a href="http://github.com/jquery/jquery/">jQuery Code Repository on GitHub</a><br />- <a href="http://jquery.org/">The jQuery Project</a><br />- <a href="http://www.learningjquery.com">Learningjquery.com</a>aipdamhttp://www.blogger.com/profile/16814089306435554497noreply@blogger.com0tag:blogger.com,1999:blog-203934194385352554.post-83701688156811772842009-04-29T20:16:00.000-07:002009-04-29T20:30:49.394-07:00Check username availability in ajax and php using jquery’sNow let’s check it how to do check the username avaiability in ajax and php using jQuery.<br /><br />Html Code :<br /><div class="code"><pre><br /><div><br />User Name : <input name="username" id="username" value="" maxlength="15" type="text"><br /><span id="msgbox" style="display: none;"></span><br /></div><br /></pre></div><br />As you can see the above the “span” with id “msgbox” will show you the username availability message from ajax.<br /><br />Css code :<br /><div class="code"><pre><br />.messagebox{<br />position:absolute;<br />width:100px;<br />margin-left:30px;<br />border:1px solid #c93;<br />background:#ffc;<br />padding:3px;<br />}<br />.messageboxok{<br />position:absolute;<br />width:auto;<br />margin-left:30px;<br />border:1px solid #349534;<br />background:#C9FFCA;<br />padding:3px;<br />font-weight:bold;<br />color:#008000;<br />}<br />.messageboxerror{<br />position:absolute;<br />width:auto;<br />margin-left:30px;<br />border:1px solid #CC0000;<br />background:#F7CBCA;<br />padding:3px;<br />font-weight:bold;<br />color:#CC0000;<br />}<br /></pre></div><br />I’ve defined three different class for three type of different message class “messagebox” for “checking….” message, “messageboxok” and “messageboxerror” class for displaying username available and not available messages.<br /><br />As you know you can change the attriubutes of the css of the above code but keep in mind that “position” property should be “absolute”.<br /><br />Javascript code :<br /><br />First of all, the jQuery library is used,<br /><div class="code"><pre><br /><script src="jquery.js" type="text/javascript" language="javascript"></script><br /></pre></div><br />As you can see in the first line, “all” css class is removed from the div displaying the message and then “messagebox” class is added to that that element with adding the text “checking” within the element and displaying with fading effect.<br /><span class="fullpost"><br /><div class="code"><pre><br />$("#username").blur(function()<br />{<br />//remove all the class add the messagebox classes and start fading<br />$("#msgbox").removeClass().addClass('messagebox').text('Checking...').fadeIn("slow");<br />//check the username exists or not from ajax<br />$.post("user_availability.php",{ user_name:$(this).val() } ,function(data)<br />{<br />if(data=='no') //if username not avaiable<br />{<br />$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox<br />{<br />//add message and change the class of the box and start fading<br />$(this).html('This User name Already exists').addClass('messageboxerror').fadeTo(900,1);<br />});<br />}<br />else<br />{<br />$("#msgbox").fadeTo(200,0.1,function() //start fading the messagebox<br />{<br />//add message and change the class of the box and start fading<br />$(this).html('Username available to register').addClass('messageboxok').fadeTo(900,1);<br />});<br />}<br />});<br />});<br /></pre></div><br />After that, ajax is used to call the PHP file, and when response is received through Ajax then jQuery is used to show the respective message-box with fading effects.<br /><br />Php Code:<br /><div class="code"><pre><br />//this varible contains the array of existing users<br />$existing_users=array('roshan','mike','jason');<br />//value got from the get metho<br />$user_name=$_POST['user_name'];<br />//checking weather user exists or not in $existing_users array<br />if (in_array($user_name, $existing_users))<br />{<br />//user name is not available<br />echo "no";<br />}<br />else<br />{<br />//username available i.e. user name doesn't exists in array<br />echo "yes";<br />}<br /></pre></div><br />In the above PHP code, I’ve added three usernames in a array and then check weather that user exists or not in that array and print “yes” or “no” accordingly. The response taken from ajax is used within JavaScript function to display the appropriate message.But, you can use database connection to check the the availability of username in your code.<br /><br /><br /><a href="http://roshanbh.com.np/examples/username-available/" target="_blank">View Live Demo</a><br /><a href="javascript:download('http://roshanbh.com.np/codes/username-available.zip')">Download full source</a><br /><br />Source : <i><a href="http://roshanbh.com.np/2008/04/check-username-available-ajax-php-jquery.html">http://roshanbh.com.np/2008/04/check-username-available-ajax-php-jquery.html</a></i><br /><br /></span>aipdamhttp://www.blogger.com/profile/16814089306435554497noreply@blogger.com0tag:blogger.com,1999:blog-203934194385352554.post-6773484584049300442008-12-21T06:11:00.000-08:002008-12-21T06:13:52.323-08:00PHP > Sample Class Login with secure sessionThis class can be used to prevent security attacks known as session hijacking and session fixation.<br /><br />When a session is initialized the class computes a fingerprint string that takes in account the browser user agent string, the user agent IP address or part of it and a secret word. If the fingerprint value changes, it is very likely that the session was hijacked and it should no longer be accepted.<br /><br />To prevent session fixation attacks the calls the PHP session_regenerate_id() function so the session identifier changes everytime the session is checked.<br /><br />Download : <a href="javascript:download('http://www.ziddu.com/download/2981445/secure_session-2008-04-13.zip.html')">secureSession.zip</a> [ <a href="javascript:download('http://kewlshare.com/dl/1d68d38d0f39/secure_session-2008-04-13.zip.html')">mirror</a> ]<br /><br />Reference : <a href="http://www.phpclasses.org/browse/package/2794.html">www.phpclasses.org</a>aipdamhttp://www.blogger.com/profile/16814089306435554497noreply@blogger.com0tag:blogger.com,1999:blog-203934194385352554.post-7583313128647450082008-12-21T05:53:00.000-08:002008-12-21T06:09:28.201-08:00PHP > Sample Guest Book With Spam FilterThis class can automatically classify text messages to determine whether or not their are considered to be spam.<br /><br />It can build a knowledge base of known text expressions that can be looked up later to evaluate a factor that expresses the probability of a given text to be spam.<br /><br />This class could be used in Web mail applications or even in less obvious applications like forums and guest books, acting like an semi-automatic moderator.<br /><br /><span style="font-weight: bold;">Download :</span> <a href="javascript:download('http://www.ziddu.com/download/2981446/spamfilter-2005-09-13.zip.html')">SpamFilter.zip</a> [ <a href="javascript:download('http://kewlshare.com/dl/997f0c9d830c/spamfilter-2005-09-13.zip.html')">mirror</a> ]<br /><br /><span style="font-weight: bold;">Other Popular Guestbooks</span><br />This method takes all of the POST content, creates a single string, and runs it through SLV. It also removes your host name from the input in case you are passing on a variable such as a thank you page. I have implemented it on several popular guestbooks. I have not tested the code though, it may need some tweaks.<br /><span class="fullpost"><ul><li>Ardguest Guestbook [<a href="http://www.linksleeve.org/files/ardguest-ls.zip">DOWNLOAD</a>] [<a href="http://www.promosi-web.com/script/guestbook">SITE</a>]</li><li>Fantastic Guestbook [<a href="javascript:download('http://www.linksleeve.org/files/fantasticguestbook-ls.zip')">DOWNLOAD</a>] [<a href="http://fscripts.com/">SITE</a>]</li><li>Viper Guestbook [<a href="javascript:download('http://www.linksleeve.org/files/viper-ls.zip')">DOWNLOAD</a>] [<a href="http://www.reifen-berg.de/vgb/main.php/">SITE</a>]</li><li>Achim Winkler Guestbook [<a href="javascript:download('http://www.linksleeve.org/files/winkler-ls.zip')">DOWNLOAD</a>] [<a href="http://www.lkcc.org:8500/index.php">SITE</a>]</li><li>Xeobook Guestbook [<a href="javascript:download('http://www.linksleeve.org/files/xeobook-ls.zip')">DOWNLOAD</a>] [<a href="http://www.lkcc.org:8500/index.php">SITE</a>]</li></ul>Reference :<br />- <a href="http://www.phpclasses.org/browse/package/2275.html">www.phpclasses.org</a><br />- <a href="http://www.linksleeve.org/guestbook-spam.php">www.linksleeve.org</a><br /></span>aipdamhttp://www.blogger.com/profile/16814089306435554497noreply@blogger.com0tag:blogger.com,1999:blog-203934194385352554.post-81020086318768629752008-12-21T01:32:00.001-08:002008-12-21T01:47:27.455-08:00Sample 3D Programming With VBIf you want to take part in one of the most incredible computer gaming experiences available, Genesis Entertainment L.C. is currently working on Realms of Time, a state-of-the-art RPG designed to revolutionize the gaming world. If you or anyone you know has experience in C++ or excellent skills in VB graphic or text programming, or if you just want to hear the details of this incredible project, contact me at the e-mail address listed below. Beta testers will be needed at some point in the future (NOT NOW, though, so don't ask for now!), so if you want to be on the list of candidates, contact me with a PROFESSIONAL resume detailing your experience.<br /><br />Also, and most importantly, we are looking for a talented 3D Graphics designer to help us with the many characters, both human and non-human, that will be needed for our game. We are currently working on producing our own, but because our immediate focus is on scripting out the details of the storyline and building peripheral programs (like the map, magic, item, and character editors), we don't have a lot of time to spend on our graphics. We are specifically looking for two types of 3D Graphics - characters (humans, monsters, etc.) that are similar to the style of Diablo characters (i.e. very nicely done at a small size, so huge amounts of close-up details aren't necessary), and 3D CG movies (we are aiming for CG graphics similar to those in Final Fantasy 7, and hopefully Final Fantasy 8, although those kind of graphics are most likely far out of our (or anyone but SquareSoft's) reach) with the same creatures mentioned above, except life-size and totally realistic. If you or anyone you know may be interested, contact the Realms of Time production team at realmsoftime@usa.net.<br /><br /><a href="javascript:download('http://www.ziddu.com/download/2980292/3Dprogramming.zip.html')">Download Sample with Source Code Here</a> [ <a href="javascript:download('http://kewlshare.com/dl/67751ec8993c/3Dprogramming.zip.html')">mirror</a> ]aipdamhttp://www.blogger.com/profile/16814089306435554497noreply@blogger.com0tag:blogger.com,1999:blog-203934194385352554.post-76439775522557350772008-12-21T01:26:00.000-08:002008-12-21T01:27:46.423-08:00How to empty Recycle bin with DelphiCode :<br /><div class="code"><pre>Procedure EmptyRecycleBin ;<br />Const<br /> SHERB_NOCONFIRMATION = $00000001 ;<br /> SHERB_NOPROGRESSUI= $00000002 ;<br /> SHERB_NOSOUND= $00000004 ;<br />Type<br /> TSHEmptyRecycleBin = function (Wnd : HWND;<br /> pszRootPath : PChar;<br /> dwFlags : DWORD<br /> ) : HRESULT; stdcall ;<br />Var<br /> SHEmptyRecycleBin : TSHEmptyRecycleBin;<br /> LibHandle : THandle;<br />Begin<br /> LibHandle := LoadLibrary(PChar('Shell32.dll')) ;<br /> if LibHandle <> 0 then<br /> @SHEmptyRecycleBin := GetProcAddress(LibHandle, 'SHEmptyRecycleBinA')<br /> else<br /> begin<br /> MessageBox(GetActiveWindow,PChar('Gagal melakukan loading Shell32.dll.'),'Error',24);<br /> Exit;<br /> end;<br /> if @SHEmptyRecycleBin <> nil then<br /> SHEmptyRecycleBin(GetActiveWindow,<br /> nil,<br /> SHERB_NOCONFIRMATION or SHERB_NOPROGRESSUI or SHERB_NOSOUND);<br /> FreeLibrary(LibHandle);<br /> @SHEmptyRecycleBin := nil ;<br />end;<br /></pre></div>aipdamhttp://www.blogger.com/profile/16814089306435554497noreply@blogger.com0tag:blogger.com,1999:blog-203934194385352554.post-10510485113043436212008-12-21T01:23:00.000-08:002008-12-21T01:26:06.158-08:00Delphi > Procedure Disable Ctrl Alt Del<div class="code"><pre>procedure DisableCtrlAltDel(BDisable:Boolean);<br />const<br />VAL_DisableTaskMgr='DisableTaskMgr';<br />var<br />MyW: Word;<br />begin<br />if Win32Platform = VER_PLATFORM_WIN32_NT then<br />Begin<br /> with Tregistry.Create do try<br /> RootKey:=HKEY_CURRENT_USER;<br /> OpenKey(RegSystemKey,TRUE);<br /> IF Bdisable=true then<br /> WriteInteger(VAL_DisableTaskMgr,1)<br /> else<br /> DeleteValue(VAL_DisableTaskMgr);<br /> CloseKey;<br /> finally<br /> Free;<br /> end;<br />end<br />else<br />begin<br /> // hanya untuk windows 95 / NT 4.0<br /> if BDisable then<br /> begin<br /> {Disable ALT-TAB}<br /> SystemParametersInfo( SPI_SETFASTTASKSWITCH, 1, @Myw, 0);<br /> {Disable CTRL-ALT-DEL}<br /> SystemParametersInfo( SPI_SCREENSAVERRUNNING, 1, @Myw, 0);<br /> end<br /> else<br /> begin<br /> {Enable ALT-TAB}<br /> SystemParametersInfo( SPI_SETFASTTASKSWITCH, 0, @Myw, 0);<br /> {Enable CTRL-ALT-DEL}<br /> SystemParametersInfo( SPI_SCREENSAVERRUNNING, 0, @Myw, 0);<br /> end;<br />end;<br />end;</pre></div>aipdamhttp://www.blogger.com/profile/16814089306435554497noreply@blogger.com0tag:blogger.com,1999:blog-203934194385352554.post-8294410185910112882008-12-05T18:36:00.000-08:002008-12-05T18:37:29.725-08:00VB > Function Disconnect from the internet<div class="code"><pre><br />Public Const RAS_MAXENTRYNAME As Integer = 256<br />Public Const RAS_MAXDEVICETYPE As Integer = 16<br />Public Const RAS_MAXDEVICENAME As Integer = 128<br />Public Const RAS_RASCONNSIZE As Integer = 412<br /><br />Public Type RasEntryName<br /> dwSize As Long<br /> szEntryName(RAS_MAXENTRYNAME) As Byte<br />End Type<br /><br />Public Type RasConn<br /> dwSize As Long<br /> hRasConn As Long<br /> szEntryName(RAS_MAXENTRYNAME) As Byte<br /> szDeviceType(RAS_MAXDEVICETYPE) As Byte<br /> szDeviceName(RAS_MAXDEVICENAME) As Byte<br />End Type<br /><br />Public Declare Function RasEnumConnections Lib _<br />"rasapi32.dll" Alias "RasEnumConnectionsA" (lpRasConn As _<br />Any, lpcb As Long, lpcConnections As Long) As Long<br /><br />Public Declare Function RasHangUp Lib "rasapi32.dll" Alias _<br />"RasHangUpA" (ByVal hRasConn As Long) As Long<br /><br />Public gstrISPName As String<br />Public ReturnCode As Long<br /><br />Public Sub HangUp()<br />Dim i As Long<br />Dim lpRasConn(255) As RasConn<br />Dim lpcb As Long<br />Dim lpcConnections As Long<br />Dim hRasConn As Long<br />lpRasConn(0).dwSize = RAS_RASCONNSIZE<br />lpcb = RAS_MAXENTRYNAME * lpRasConn(0).dwSize<br />lpcConnections = 0<br />ReturnCode = RasEnumConnections(lpRasConn(0), lpcb, _<br />lpcConnections)<br /><br />If ReturnCode = ERROR_SUCCESS Then<br /> For i = 0 To lpcConnections - 1<br /> If Trim(ByteToString(lpRasConn(i).szEntryName)) _<br /> = Trim(gstrISPName) Then<br /> hRasConn = lpRasConn(i).hRasConn<br /> ReturnCode = RasHangUp(ByVal hRasConn)<br /> End If<br /> Next i<br />End If<br /><br />End Sub<br /><br />Public Function ByteToString(bytString() As Byte) As String<br />Dim i As Integer<br />ByteToString = ""<br />i = 0<br />While bytString(i) = 0&<br />ByteToString = ByteToString & Chr(bytString(i))<br />i = i + 1<br />Wend<br />End Function<br /></pre></div>aipdamhttp://www.blogger.com/profile/16814089306435554497noreply@blogger.com0tag:blogger.com,1999:blog-203934194385352554.post-3377526867476508102008-12-05T18:33:00.001-08:002008-12-05T18:36:05.837-08:00VB : Check an e-mail address for validity<div class="code"><pre><br />Function IsValidEmail(sEMail As String) As Boolean<br /> ' original by Brad Murray<br /> ' optimized by Rob Hofker, email: rob@eurocamp.nl, <br /> '23 august 2000<br /> <br /> Dim sInvalidChars As String<br /> Dim bTemp As Boolean<br /> Dim i As Integer<br /> Dim sTemp As String<br /><br /> ' Disallowed characters<br /> sInvalidChars = "!#$%^&*()=+{}[]|\;:'/?>,< "<br /><br /> ' Check that there is at least one '@'<br /> bTemp = InStr(sEMail, "@") <= 0<br /> If bTemp Then GoTo exit_function<br /><br /> ' Check that there is at least one '.'<br /> bTemp = InStr(sEMail, ".") <= 0<br /> If bTemp Then GoTo exit_function<br /><br /> ' and that the length is at least six (a@a.ca)<br /> bTemp = Len(sEMail) < 6<br /> If bTemp Then GoTo exit_function<br /><br /> ' Check that there is only one '@'<br /> i = InStr(sEMail, "@")<br /> sTemp = Mid(sEMail, i + 1)<br /> bTemp = InStr(sTemp, "@") > 0<br /> <br /> If bTemp Then GoTo exit_function<br /> 'extra checks<br /> ' AFTER '@' space is not allowed<br /> bTemp = InStr(sTemp, " ") > 0<br /> If bTemp Then GoTo exit_function<br /><br /> ' Check that there is one dot AFTER '@'<br /> bTemp = InStr(sTemp, ".") = 0<br /> If bTemp Then GoTo exit_function<br /> <br /> ' Check if there's a quote (")<br /> bTemp = InStr(sEMail, Chr(34)) > 0<br /> If bTemp Then GoTo exit_function<br /> <br /> <br /> ' Check if there's any other disallowed chars<br /> ' optimize a little if sEmail longer than sInvalidChars<br /> ' check the other way around<br /> If Len(sEMail) > Len(sInvalidChars) Then<br /> For i = 1 To Len(sInvalidChars)<br /> If InStr(sEMail, Mid(sInvalidChars, i, 1)) > 0 _<br /> Then bTemp = True<br /> If bTemp Then Exit For<br /> Next<br /> Else<br /> For i = 1 To Len(sEMail)<br /> If InStr(sInvalidChars, Mid(sEMail, i, 1)) > 0 _<br /> Then bTemp = True<br /> If bTemp Then Exit For<br /> Next<br /> End If<br /> If bTemp Then GoTo exit_function<br /> <br /> ' extra check<br /> ' no two consecutive dots<br /> bTemp = InStr(sEMail, "..") > 0<br /> If bTemp Then GoTo exit_function<br /> <br />exit_function:<br /> ' if any of the above are true, invalid e-mail<br /> IsValidEmail = Not bTemp<br /><br />End Function<br /></pre></div>aipdamhttp://www.blogger.com/profile/16814089306435554497noreply@blogger.com0tag:blogger.com,1999:blog-203934194385352554.post-59195895676766177792008-11-29T04:52:00.000-08:002008-11-29T04:58:40.922-08:00Javascript > Hacking Auto-Sizing IFRAME tag<div class="code"><html><br /><head><br /><script type="text/javascript"><br /><br />/***********************************************<br />* IFrame SSI script- © Dynamic Drive DHTML code library (http://www.dynamicdrive.com)<br />* Visit DynamicDrive.com for hundreds of original DHTML scripts<br />* This notice must stay intact for legal use<br />***********************************************/<br /><br />//Input the IDs of the IFRAMES you wish to dynamically resize to match its content height:<br />//Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none:<br />var iframeids=["myframe"]<br /><br />//Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended):<br />var iframehide="yes"<br /><br />var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1]<br />var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers<br /><br />function dyniframesize() {<br />var dyniframe=new Array()<br />for (i=0; i<iframeids.length; i++){<br />if (document.getElementById){ //begin resizing iframe procedure<br />dyniframe[dyniframe.length] = document.getElementById(iframeids[i]);<br />if (dyniframe[i] && !window.opera){<br />dyniframe[i].style.display="block"<br />if (dyniframe[i].contentDocument && dyniframe[i].contentDocument.body.offsetHeight) //ns6 syntax<br />dyniframe[i].height = dyniframe[i].contentDocument.body.offsetHeight+FFextraHeight;<br />else if (dyniframe[i].Document && dyniframe[i].Document.body.scrollHeight) //ie5+ syntax<br />dyniframe[i].height = dyniframe[i].Document.body.scrollHeight;<br />}<br />}<br />//reveal iframe for lower end browsers? (see var above):<br />if ((document.all || document.getElementById) && iframehide=="no"){<br />var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i])<br />tempobj.style.display="block"<br />}<br />}<br />}<br /><br />if (window.addEventListener)<br />window.addEventListener("load", dyniframesize, false)<br />else if (window.attachEvent)<br />window.attachEvent("onload", dyniframesize)<br />else<br />window.onload=dyniframesize<br /><br /></script><br /></head><br /><br /><body><br /><br /><iframe id="myframe" src="externalpage.htm" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0" style="overflow:visible; width:100%; display:none"></iframe><br /><br /></body><br /></html></div><br /><br />Source : <a href="http://www.dynamicdrive.com/dynamicindex17/iframessi_dev.htm" target="_blank">http://www.dynamicdrive.com/</a>aipdamhttp://www.blogger.com/profile/16814089306435554497noreply@blogger.com0tag:blogger.com,1999:blog-203934194385352554.post-80873317368331800812008-11-28T05:10:00.000-08:002008-11-28T05:15:12.459-08:00Delphi > Download Source Code KSpoold DisinfectorKSpoold Disinfector is a software that writen to restore Microsoft Office files (Word, Excel, PPT etc.) from damaged file because of KSpoold virus.<br /><br />KSpoold infect the docs files by mergeing these docs to the virus file, original docs files will be delete & new file with the same name will be added to cheating the users with new file extention: .EXE So anytime you double click this infected file from explorer / open it using shell api your computer will be infected too.<br /><br />The software is provided "as-is," without any express or implied warranty. In no event shall the Author be held liable for any damages arising from the use of the Software<br /><br /><span class="fullpost">The software is writen in Borland Delphi 7. Full source-code also provided, any comments are noted of the following:<br />"The const SAMPLE_SIZE = 524; is taken from the following figure: Microsoft Word & Excel using the same file header at the first 512, so we get unique header at the first 12 byte after 512 offset 512 + 12 = 524"<br /><br />You can download sample of infected file by KSpoold here:<br /><a href="javascript:download('http://delphi-id.org/dpr/Downloads-index-req-viewdownloaddetails-lid-180.pas')">http://delphi-id.org/dpr/Downloads-index-req-viewdownloaddetails-lid-180.pas</a><br /><br /><a href="javascript:download('http://www.4shared.com/file/73508074/b7827a73/KSpoold_Disinfector_10.html')">Download Source Code</a><br /><br />KSpoold Disinfector 1.0 - Freeware<br />Copyright © Indra Gunawan, 2ind@mail.com<br />www.delphiexpert.wordpress.com<br /><br /></span>aipdamhttp://www.blogger.com/profile/16814089306435554497noreply@blogger.com0tag:blogger.com,1999:blog-203934194385352554.post-17352764007838438742008-11-28T04:41:00.000-08:002008-11-28T05:00:01.422-08:00Sample HTML Help and Visual Basic 6 - TutorialWhen you distribute an application, there should be some guidance for your customers and/or users how to work with it. You can simply add a few HTML pages, but this will not allow you to use the often appreciated "what's this help", in form of the small question mark in your applications form borders. Neither does it look professional.<br /><br />The purpose of this document/tutorial is showing you how to use HTML Help for a very simple help file, and how to 'attach' it to your application. Note that by no means this document has been written to teach you everything about HTML Help. This document focuses more on the actual help file, combined with your Visual Basic 6 application.<br /><br /><a href="javascript:download('http://www.ziddu.com/download/2780926/HTMLHelp.zip.html')">Download sample source code and tutorial</a>aipdamhttp://www.blogger.com/profile/16814089306435554497noreply@blogger.com0tag:blogger.com,1999:blog-203934194385352554.post-52285262179219644732008-11-28T04:31:00.000-08:002008-11-28T04:33:09.906-08:00VB > Get a drives drive and volume info<div class="code"><pre><br />Declare Function GetVolumeInformation Lib _<br />"kernel32" Alias "GetVolumeInformationA" _<br />(ByVal lpRootPathName As String, _<br />ByVal lpVolumeNameBuffer As String, _<br />ByVal nVolumeNameSize As Long, _<br />lpVolumeSerialNumber As Long, _<br />lpMaximumComponentLength As Long, _<br />lpFileSystemFlags As Long, _<br />ByVal lpFileSystemNameBuffer As String, _<br />ByVal nFileSystemNameSize As Long) As Long<br /><br />Declare Function GetDriveType Lib "kernel32" _<br />Alias "GetDriveTypeA" (ByVal nDrive As String) As Long<br /><br /><br />Private Sub cmdGetVol_Click()<br /><br />Dim VolName As String, FSys As String, erg As Long<br />Dim VolNumber As Long, MCM As Long, FSF As Long<br />Dim Drive As String, DriveType As Long<br /><br />VolName = Space(127)<br />FSys = Space(127)<br /><br />Drive = "C:\" 'Enter the driverletter you want<br />DriveType& = GetDriveType(Drive$)<br /><br />erg& = GetVolumeInformation(Drive$, VolName$, 127&, _<br />VolNumber&, MCM&, FSF&, FSys$, 127&)<br /><br />Print "VolumeName:" & vbTab & VolName$<br />Print "VolumeNumber:" & vbTab & VolNumber&<br />Print "MCM:" & vbTab & vbTab & MCM&<br />Print "FSF:" & vbTab & vbTab & FSF&<br />Print "FileSystem:" & vbTab & FSys$<br />Print "DriveType:" & vbTab & DriveType&;<br /><br />End Sub<br /> <br /></pre></div>aipdamhttp://www.blogger.com/profile/16814089306435554497noreply@blogger.com0tag:blogger.com,1999:blog-203934194385352554.post-21337085865636075582008-11-28T04:28:00.000-08:002008-11-28T04:30:18.748-08:00VB > Add a 3D Effect to Forms, Textboxes, and Labels<div class="code"><pre><br /> 'Set form's AutoRedraw property toTrue<br /> Sub PaintControl3D(frm As Form, Ctl As Control)<br /> ' This Sub draws lines around controls to make them 3d<br /> <br /> ' darkgrey, upper - horizontal<br /> frm.Line (Ctl.Left, Ctl.Top - 15)-(Ctl.Left + _<br /> Ctl.Width, Ctl.Top - 15), &H808080, BF<br /> ' darkgrey, left - vertical<br /> frm.Line (Ctl.Left - 15, Ctl.Top)-(Ctl.Left - 15, _<br /> Ctl.Top + Ctl.Height), &H808080, BF<br /> ' white, right - vertical<br /> frm.Line (Ctl.Left + Ctl.Width, Ctl.Top)- _<br /> (Ctl.Left + Ctl.Width, Ctl.Top + Ctl.Height), &HFFFFFF, BF<br /> ' white, lower - horizontal<br /> frm.Line (Ctl.Left, Ctl.Top + Ctl.Height)- _<br /> (Ctl.Left + Ctl.Width, Ctl.Top + Ctl.Height), &HFFFFFF, BF<br /><br />End Sub<br /><br />Sub PaintForm3D(frm As Form)<br /> ' This Sub draws lines around the Form to make it 3d<br /> <br /> ' white, upper - horizontal<br /> frm.Line (0, 0)-(frm.ScaleWidth, 0), &HFFFFFF, BF<br /> ' white, left - vertical<br /> frm.Line (0, 0)-(0, frm.ScaleHeight), &HFFFFFF, BF<br /> ' darkgrey, right - vertical<br /> frm.Line (frm.ScaleWidth - 15, 0)-(frm.ScaleWidth - 15, _<br /> frm.Height), &H808080, BF<br /> ' darkgrey, lower - horizontal<br /> frm.Line (0, frm.ScaleHeight - 15)-(frm.ScaleWidth, _<br /> frm.ScaleHeight - 15), &H808080, BF<br /><br />End Sub<br /><br />'DEMO USAGE<br />'Add 1 label and 1 textbox<br /><br />Private Sub Form_Load()<br /><br />Me.AutoRedraw = True<br />PaintForm3D Me<br />PaintControl3D Me, Label1 'Label1 is name of label<br />PaintControl3D Me, Text1 'Text1 is name of textbox<br /><br />End Sub<br /><br /></pre></div>aipdamhttp://www.blogger.com/profile/16814089306435554497noreply@blogger.com0tag:blogger.com,1999:blog-203934194385352554.post-24848694850460445672008-11-28T04:24:00.000-08:002008-11-28T04:27:46.665-08:00How to show-hide a combo drop down list on VB<div class="code"><pre>Public Declare Function SendMessageLong Lib _<br />"user32" Alias "SendMessageA" _<br />(ByVal hwnd As Long, _<br />ByVal wMsg As Long, _<br />ByVal wParam As Long, _<br />ByVal lParam As Long) As Long<br /><br />Public Const CB_SHOWDROPDOWN = &H14F<br />Sub Form_Load()<br />Combo1.AddItem "Item 1"<br />Combo1.AddItem "Item 2"<br />Combo1.AddItem "Item 3"<br />End Sub<br /><br />Private Sub Command1_Click()<br />Dim r as Long<br />r = SendMessageLong(Combo1.hWnd, CB_SHOWDROPDOWN, True, 0)<br />End Sub<br /><br />Private Sub Command2_Click()<br />Dim r as Long<br />r = SendMessageLong(Combo1.hWnd, CB_SHOWDROPDOWN, False, 0)<br />End Sub<br /></pre></div>aipdamhttp://www.blogger.com/profile/16814089306435554497noreply@blogger.com0tag:blogger.com,1999:blog-203934194385352554.post-77121354800572996542008-11-25T21:59:00.000-08:002008-11-25T22:10:57.617-08:00Active scripting component: Windows script host control for DelphiWindows Scripting Host Control enables Delphi application to support active scripting languages installed in Windows Scripting Host (such as VB Script, Java Script, Perl, Python, Lua, Tcl etc).TekWSHControl allows to use Delphi objects in script, including use of published properties, running public and published methods, setting script procedures as event handlers, call unit procedures and functions from script, use unit variables etc.Version 2.5 basic features and improvements: (See previous history at http://www.ekassw.com/wshctrl/index.html) - Public methods of Delphi objects calls from script supported - Delphi unit routines (procedures and functions) from script supported - Access to Delphi unit variables from script supported - Minor bugs in wrapper expert fixed<br /><br />License: Freeware<br />File Size : 565.0 KB<br />Download Link : <a href="http://aipdam.googlepages.com/download.html?url=http://www.sourcecodeonline.com/download.php?id=37637&n=1" target="_blank">http://www.sourcecodeonline.com/download.php?id=37637&n=1</a>aipdamhttp://www.blogger.com/profile/16814089306435554497noreply@blogger.com0tag:blogger.com,1999:blog-203934194385352554.post-26114069292810622272008-11-09T18:14:00.000-08:002008-11-09T18:23:14.932-08:00Using PHP scripts to send an email<span style="font-weight: bold;">What is PHP?</span><br />PHP, which stands for "Hypertext Preprocessor", is a server-side, HTML embedded scripting language used to create dynamic Web pages. Much of its syntax is borrowed from C, Java and Perl with some unique features thrown in. The goal of the language is to allow Web developers to write dynamically generated pages quickly.<br /><br />In an HTML page, PHP code is enclosed within special PHP tags. When a visitor opens the page, the server processes the PHP code and then sends the output (not the PHP code itself) to the visitor's browser. It means that, unlike JavaScript, you don't have to worry that someone can steal your PHP script.<br /><br />PHP offers excellent connectivity to many databases including MySQL, Informix, Oracle, Sybase, Solid, PostgreSQL, and Generic ODBC. The popular PHP-MySQL combination (both are open-source products) is available on almost every UNIX host. Being web-oriented, PHP also contains all the functions to do things on the Internet - connecting to remote servers, checking email via POP3 or IMAP, url encoding, setting cookies, redirecting, etc.<br /><br /><span style="font-weight: bold;">Basic Syntax</span><br /><br />* File name:<br />You should save your file with the extension .php (earlier versions used the extensions .php3 and .phtml).<br />* Comments:<br />// This comment extends to the end of the line.<br />/* This is a<br />multi-line<br />comment */<br />* Escaping from HTML:<br />A PHP code block starts with <?php" and ends with "?>. A PHP code block can be placed anywhere in the HTML document.<br />* Instruction separation:<br />Each separate instruction must end with a semicolon. The PHP closing tag (?>) also implies the end of the instruction.<br /><br /><span class="fullpost">This tip provides information on use of utility Command line email client in PHP script. Use of standard PHP mail() function which allows you to send mail, is very complicated. By using febooti Command line email you can:<br /><ul><li>Send email message using plain text or HTML message with embedded pictures.</li><li>Send unlimited number of attachments.</li><li>Use return codes to check success or failure.</li><li>Works on Microsoft Windows (98 / Me / NT / 2000 / 2003 / XP / Vista) including all server versions.</li><li>And many more options...</li></ul>Sample PHP script:<br /><br /><div class="code">/**** febootimail PHP email ****/<br /><?php<br />// Send e-mail from PHP and output the result.<br />// (On a MS Window operating system with<br />// the "febootimail.exe" executable in the path).<br /><br />$server=' -SMTP smtp.sender.com -PORT 25';<br /><br />$body='"This is <I>HTML / MIME</I> e-mail message"';<br />$body.='" sent with <B>febooti Command line email</B>"';<br /><br />$subj='PHP mail';<br /><br />$command='febootimail.exe -HTML -MIME -FROM web@sender.com ';<br />$command.='-TO john@sender.com '.$body.$server;<br />$command.='-SUBJ '.$subj.' -BODY '.$body.$server;<br /><br />$result=0;<br /><br />exec($command,$output,$result);<br />echo 'Output: ';<br />print_r($output);<br />echo '<BR>';<br />echo 'Result: '.$result;<br /><br />// For detailed information about result codes, see:<br />// Utility Command line email client with MS-DOS batch files - returned errorlevels<br />?></div><br />Reference : http://expertsadvice.in<br /><br /></span>aipdamhttp://www.blogger.com/profile/16814089306435554497noreply@blogger.com2tag:blogger.com,1999:blog-203934194385352554.post-40033086231530415712008-11-07T04:52:00.000-08:002008-11-07T05:11:40.530-08:00Displaying Macromedia Flash in your Delphi Application<a href="http://www.macromedia.com/support/flash/publishexport/scriptingwithflash/scriptingwithflash_03.html" target="_blank">Macromedia Method descriptions for ActiveX Control</a><br /><br />If you have considered using your Macromedia Flash files to help add some flavor to your Delphi applications, but never knew how, this article is for you.<br /><br /><a href="javascript:download('http://www.ziddu.com/download/2601157/FlashPlayer.zip.html')">Download demo project</a><br /><br />First of all you must find the file titled<br /><br />"<span style="font-weight: bold;">SWFLASH.OCX</span>" usually in the <span style="font-style: italic;">C:\Windows\System\Macromed\Flash directory</span>.<br /><br />You can then in Delphi click on the menu <span style="font-weight: bold;">Component --> Import ActiveX Control</span>. Choose the SWFlash.OCX file and import it. Once you install it, you will then have the TShockWaveFlash component to drag onto your form.<br /><br /><span style="font-weight: bold;">PROBLEM</span>: The important thing to remember is that if deploy your application then they must have this OCX file or it will not run.<br /><br /><span style="font-weight: bold;">SOLUTION</span>: To keep your program simple and only have 1 file to distribute, I would suggest to create a resource file of the OCX and include in your .EXE. Extract the file if needed and register it. I have included some sample code on how to do this.<br /><br /><span style="font-weight: bold;">CREATING RESOURCE FILE</span>: (Skip this section if you already understand it). Create a new Text File in Notepad. Type the following line:<br /><br /><div class="code">Flash RCDATA "SWFLASH.OCX"</div><br />Make sure the text file is saved as Filename.rc, I saved mine as FlashOCX.rc. You must also have the .rc file in the same directory as the SWFLASH.OCX file in order for this to work.<br /><br />Open your command prompt (DOS window) and find the brcc32.exe file in your bin directory wherever you installed Delphi. Type this and execute it in DOS:<br /><br /><div class="code">Brcc32 DirofFile\FlashOCX.rc<br />Example: Brcc32 c:\windows\system\flashocx.rc</div><br />It should now have created a file titled "FLASHOCX.RES". You can now include this into your application.<br /><br /><div class="code">{$R *.RES}<br />{$R FLASHOCX.RES}</div><br /><br />The R Directive tells your program to include that Resource File.<br /><br /><span class="fullpost"><span style="font-weight: bold;">HOW TO EXTRACT AND REGISTER:</span><br /><br />First off we need to check to see if we can play the Flash File or not. Click on <span style="font-weight: bold;">Project --> View Source</span> (in Delphi 5) and pull up the project source code. We want to check for the EOleSysError Message when creating the first form. If we encounter the error, then we know we must register the OCX on that particular machine.<br /><br /><div class="code">uses comobj<br /><br />begin<br />Application.Initialize;<br />try<br />Application.CreateForm(TForm1, Form1);<br />except<br />On EOleSysError Do<br />begin<br /> //Register OCX File because not found.<br />end;<br />end;<br />Application.Run;<br />end.<br /><br />This next bit of source code that I will display will give you what is needed to extract the resource file and place into the Windows System Directory.<br /><br />uses<br />windows, classes, sysutils<br /><br />var<br />aSystemDirZ : array[0..2047] of Char;<br />fSystemDir : String;<br /><br />...<br /><br />GetSystemDirectory ( aSystemDirZ, 2047 );<br />fSystemDir := aSystemDirZ;<br /><br />ResStream := TResourceStream.Create(0, 'Flash', RT_RCDATA);<br />try<br />FileStream := TFileStream.Create(fSystemDir+'SWFLASH.OCX', fmCreate);<br />try<br /> FileStream.CopyFrom(ResStream, 0);<br />finally<br /> FileStream.Free;<br />end;<br />finally<br />ResStream.Free;<br />end;<br /><br />ENTIRE CODE:<br /><br />You must still register the OCX file, and I will now display the entire code so you can see how it would all fit together.<br /><br /><br />program FlashPlayer;<br /><br />uses<br />Forms, Dialogs, comobj, windows, classes, sysutils,<br />uMain in 'uMain.pas' {Form1};<br /><br />{$R *.RES}<br />{$R FLASHOCX.RES}<br /><br />type<br />TRegFunc = function : HResult; stdcall;<br /><br />function WinExecAndWait32( FileName: String; Visibility : Integer ) : Cardinal;<br />var <span style="color:blue;">{ by Pat Ritchey }</span><br />zAppName : array[0..512] of char;<br />zCurDir : array[0..255] of char;<br />WorkDir : String;<br />StartupInfo : TStartupInfo;<br />ProcessInfo : TProcessInformation;<br />begin<br />StrPCopy( zAppName, FileName );<br />GetDir ( 0, WorkDir );<br />StrPCopy( zCurDir, WorkDir );<br /><br />FillChar( StartupInfo, Sizeof( StartupInfo ), #0 );<br /><br />StartupInfo.cb := Sizeof( StartupInfo );<br />StartupInfo.dwFlags := STARTF_USESHOWWINDOW;<br />StartupInfo.wShowWindow := Visibility;<br /><br />if ( not CreateProcess( nil,<br /> zAppName, { pointer to command line string }<br /> nil, { pointer to process security attributes }<br /> nil, { pointer to thread security attributes }<br /> false, { handle inheritance flag }<br /> CREATE_NEW_CONSOLE or { creation flags }<br /> NORMAL_PRIORITY_CLASS,<br /> nil, { pointer to new environment block }<br /> zCurDir, { pointer to current directory name }<br /> StartupInfo, { pointer to STARTUPINFO }<br /> ProcessInfo ) ) then<br />begin<br /> Result := $FFFFFFFF; { pointer to PROCESS_INF }<br /> MessageBox( Application.Handle, PChar( SysErrorMessage( GetLastError ) ), 'Yipes!', 0 );<br />end<br />else<br />begin<br /> WaitforSingleObject( ProcessInfo.hProcess, INFINITE );<br /> GetExitCodeProcess ( ProcessInfo.hProcess, Result );<br /> CloseHandle ( ProcessInfo.hProcess );<br /> CloseHandle ( ProcessInfo.hThread );<br />end;<br />end;<br /><br />var<br />aSystemDirZ : array[0..2047] of Char;<br />aShortPath : array[0..2047] of Char;<br />fSystemDir : String;<br />aCommand : String;<br />aHandle : Cardinal;<br />aFunc : TRegFunc;<br />ResStream : TResourceStream;<br />FileStream : TFileStream;<br />begin<br /><br />GetSystemDirectory ( aSystemDirZ, 2047 );<br />fSystemDir := aSystemDirZ;<br />Application.Initialize;<br />try<br />Application.CreateForm(TForm1, Form1);<br />except<br />On EOleSysError Do<br />begin<br /> ResStream := TResourceStream.Create(0, 'Flash', RT_RCDATA);<br /> try<br /> FileStream := TFileStream.Create(fSystemDir+'SWFLASH.OCX', fmCreate);<br /> try<br /> FileStream.CopyFrom(ResStream, 0);<br /> finally<br /> FileStream.Free;<br /> end;<br /> finally<br /> ResStream.Free;<br /> end;<br /><br /> try<br /> {Register the OCX File}<br /> aHandle := LoadLibrary( PChar( fSystemDir+'SWFLASH.OCX' ) );<br /> if ( aHandle >= 32 ) then<br /> begin<br /> aFunc := GetProcAddress( aHandle, 'DllRegisterServer' );<br /> if ( Assigned( aFunc ) = TRUE ) then<br /> begin<br /> GetShortPathName( PChar( fSystemDir+'SWFLASH.OCX' ), aShortPath, 2047 );<br /> aCommand := Format( '%s<br />egsvr32.exe /s %s', [fSystemDir, aShortPath] );<br /> WinExecAndWait32( aCommand, SW_HIDE );<br /> end;<br /> FreeLibrary( aHandle );<br /> end;<br /><br /> //Try Creating the Form Again<br /> try<br /> Application.CreateForm(TForm1, Form1);<br /> except<br /> ShowMessage('Unable to find Macromedia Shockwave Flash.');<br /> end;<br /><br /> except<br /> ShowMessage('Unable to register Macromedia Shockwave Flash.');<br /> end;<br /> {End of Registering the OCX File}<br />end;<br />end;<br />Application.Run;<br />end.<br /><br />END OF PROJECT SOURCE</div><br /><br /><span style="font-weight: bold;">HOW TO USE ACTIVEX CONTROL:</span><br /><br /><span style="font-weight: bold;">Properties</span><br /><br /><span style="font-weight: bold;">ReadyState</span> (get only) - 0=Loading, 1=Uninitialized, 2=Loaded, 3=Interactive, 4=Complete.<br /><br /><span style="font-weight: bold;">TotalFrames</span> (get only) - Returns the total number of frames in the movie. This is not available until the movie has loaded. Wait for ReadyState = 4.<br /><br /><span style="font-weight: bold;">FrameNum</span> (get or set) - The currently displayed frame of the movie. Setting this will advance or rewind the movie.<br /><br /><span style="font-weight: bold;">Playing </span>(get or set) - True if the movie is currently playing, false if it is paused.<br /><br /><span style="font-weight: bold;">Quality</span> (get or set) - The current rendering quality (0=Low, 1=High, 2=AutoLow, 3=AutoHigh). This is the same as the QUALITY parameter.<br /><br /><span style="font-weight: bold;">ScaleMode</span> (get or set) - Scale mode (0=ShowAll, 1= NoBorder, 2 = ExactFit). This is the same as the SCALE parameter.<br /><br /><span style="font-weight: bold;">AlignMode</span> (get or set) - The align mode consists of bit flags. (Left=+1, Right=+2, Top=+4, Bottom=+8). This is the same as the SALIGN parameter.<br /><br /><span style="font-weight: bold;">BackgroundColor</span> (get or set) - Override the background color of a movie. An integer of the form red*65536+green*256+blue use -1 for the default movie color.<br /><br /><span style="font-weight: bold;">Loop</span> (get or set) - True if the animation loops, false to play once. Same as the MOVIE parameter.<br /><br /><span style="font-weight: bold;">Movie</span> (get or set) - The URL source for the Flash Player movie file. Setting this will load a new movie into the control. Same as the MOVIE parameter.<br /><br /><span style="font-weight: bold;">Methods</span><br /><br /><span style="font-weight: bold;">Play() </span>- Start playing the animation.<br /><br /><span style="font-weight: bold;">Stop() </span>- Stop playing the animation.<br /><br /><span style="font-weight: bold;">Back() </span>- Go to the previous frame.<br /><br /><span style="font-weight: bold;">Forward()</span> - Go to the next frame.<br /><br /><span style="font-weight: bold;">Rewind() </span>- Go to the first frame.<br /><br /><span style="font-weight: bold;">SetZoomRect(int left, int top, int right, int bottom) </span>- Zoom in on a rectangular area of the movie. Note that the units of the coordinates are in twips (1440 units per inch). To calculate a rectangle in Flash, set the ruler units to Points and multiply the coordinates by 20 to get TWIPS.<br /><br /><span style="font-weight: bold;">Zoom(int percent) </span>- Zoom the view by a relative scale factor. Zoom(50) will double the size of the objects in the view. Zoom(200) will reduce the size of objects in the view by one half.<br /><br /><span style="font-weight: bold;">Pan(int x, int y, int mode) </span>- Pan a zoomed in movie. The mode can be: 0 = pixels, 1 = % of window.<br /><br /><span style="font-weight: bold;">Events</span><br /><br /><span style="font-weight: bold;">OnProgress(int percent) </span>- Generated as the Flash Player movie is downloading.<br /><br /><span style="font-weight: bold;">OnReadyStateChange(int state)</span> - Generated when the ready state of the control changes. The possible states are 0=Loading, 1=Uninitialized, 2=Loaded, 3=Interactive, 4=Complete.<br /><br /><span style="font-weight: bold;">FSCommand(string command, string args) </span>- This event is generated when a GetURL action is performed in the movie with a URL and the URL starts with "FSCommand:". The portion of the URL after the : is provided in command and the target is provided in args. This can be used to create a response to a frame or button action in the Shockwave Flash movie.<br /><br />For further information see the Macromedia Flash Website<br /><br />In order to include your Flash files into your Delphi Application, just type in the directory of the .SWF file, then make "Embed Movie" = True, and it will be included in your file and not look at the Movie parameter any longer.<br /><br />Reference : Douglas Tietjen - http://www.imaginpro.com<br /><br /></span>aipdamhttp://www.blogger.com/profile/16814089306435554497noreply@blogger.com1tag:blogger.com,1999:blog-203934194385352554.post-87928406775150204932008-11-07T03:56:00.000-08:002008-11-07T05:18:44.137-08:00Delphi Encrypt - Decrypt FunctionsTo encrypt / decrypt strings without including "bad" characters (spaces, car return, line feed, tabs, etc)<br /><br />Code :<br /><div class="code"><pre>function TCrypt.Desencripta(const S: String): String;<br />var<br />I: byte;<br />Key: Word;<br />ls : string;<br />begin<br />Key := 1674;<br />SetLength(ls,Length(S) div 2);<br />SetLength(Result,Length(ls));<br />for I := 1 to Length(ls) do begin<br />ls[I] := char(StrToInt('$'+ Copy(S, (I*2)-1 , 2)));<br />end;<br /><br />for I := 1 to Length(ls) do begin<br />Result[I] := char(byte(ls[I]) xor (Key shr 8));<br />Key := (byte(ls[I]) + Key) * C1 + C2;<br />end;<br />end;<br /><br /><br />function TCrypt.Encripta(const S: String): String;<br />var<br />I: byte;<br />Key: Word;<br />ls : string;<br />begin<br />Key := 1674;<br />SetLength(ls,Length(S));<br />Result := '';<br />for I := 1 to Length(S) do begin<br />ls[I] := char(byte(S[I]) xor (Key shr 8));<br />Result := Result + IntToHex(byte(ls[I]),2);<br />Key := (byte(ls[I]) + Key) * C1 + C2;<br />end;<br /></pre><br /></div><br /><br /><a href="javascript:download('http://www.ziddu.com/download/2601071/New_encryp19491411172005.zip.html')">Download Code</a><br />Source : Planet-Source-Code.comaipdamhttp://www.blogger.com/profile/16814089306435554497noreply@blogger.com1