|
Search Tech-Forums - link takes you to our Forum's search page. Note: The following is only a text archive! To view the actual forum discussion, please visit our website at http://www.tech-forums.net Pages:1 Expanding This Forum...(Programmers Unite)(Click here to view the original thread with full colors/images)Posted by: D.Viddy Let's all post some of our favorite code snippets for any language we choose. Be sure to label what it does and add any extra info that would be required. I'll start... [b]Language: Visual Basic 6.0 Purpose: Change the Windows Wallpaper[/b] [SIZE=1][CODE]Declare Function SystemParametersInfo Lib "user32" Alias "SystemParametersInfoA" _ (ByVal uAction As Long, ByVal uParam As Long, ByVal lpvParam As Any, ByVal fuWinIni As Long As Long Public Const SPI_SETDESKWALLPAPER = 20 Public Sub ChangePaper(strFilename as string) Dim lngSuccess As Long lngSuccess = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, strFilename, 0) End Sub[/CODE][/SIZE] - Please Post... Posted by: shan PHP Alternating talbe row colors. [PHP] <? $usr = "usr"; $pass = "pass"; $db = "database"; mysql_connect(localhost,$usr,$pass); mysql_select_db($db) or die("Unable to locate database becuase: mysqlerror()"); $qry = ("SELECT * FROM table ORDER by id")or die(mysql_error()); $result = mysql_query($qry); $numrows = mysql_num_rows($result); echo "<table width='100%' border=1 cellpadding=2 cellspacing=2>\n"; echo "<tr><th bgcolor='#FFFFFF'><font color='black'>Something</th> <th bgcolor='#FFFFFF'><font color='black'>Something else</th> <th bgcolor='#FFFFFF'><font color='black'>Something different</font></th></tr>\n"; $bg = "#000000"; for ($cur = 0; $cur < $numrows; $cur++){ if ($bg == "#000000"){ $bg = "#123456"; }else{ $bg = "#000000"; } $row = mysql_fetch_array($result); echo "<tr>\n"; echo "<td bgcolor='$bg'>".$row['something']."</td>\n"; echo "<td bgcolor='$bg'>".$row['somethingelse']."</td>\n"; echo "<td bgcolor='$bg'>".$row['somethingdifferent']."</td>\n"; echo "</tr>\n"; } print "</table>\n"; mysql_close(); ?> [/php] Posted by: þÄ®âÐÖx Registry Access (Visual Basic) [CODE]'This program needs 3 buttons Const REG_SZ = 1 ' Unicode nul terminated string Const REG_BINARY = 3 ' Free form binary Const HKEY_CURRENT_USER = &H80000001 Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long Private Declare Function RegDeleteValue Lib "advapi32.dll" Alias "RegDeleteValueA" (ByVal hKey As Long, ByVal lpValueName As String) As Long Private Declare Function RegOpenKey Lib "advapi32.dll" Alias "RegOpenKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long Function RegQueryStringValue(ByVal hKey As Long, ByVal strValueName As String) As String Dim lResult As Long, lValueType As Long, strBuf As String, lDataBufSize As Long 'retrieve nformation about the key lResult = RegQueryValueEx(hKey, strValueName, 0, lValueType, ByVal 0, lDataBufSize) If lResult = 0 Then If lValueType = REG_SZ Then 'Create a buffer strBuf = String(lDataBufSize, Chr$(0)) 'retrieve the key's content lResult = RegQueryValueEx(hKey, strValueName, 0, 0, ByVal strBuf, lDataBufSize) If lResult = 0 Then 'Remove the unnecessary chr$(0)'s RegQueryStringValue = Left$(strBuf, InStr(1, strBuf, Chr$(0)) - 1) End If ElseIf lValueType = REG_BINARY Then Dim strData As Integer 'retrieve the key's value lResult = RegQueryValueEx(hKey, strValueName, 0, 0, strData, lDataBufSize) If lResult = 0 Then RegQueryStringValue = strData End If End If End If End Function Function GetString(hKey As Long, strPath As String, strValue As String) Dim Ret 'Open the key RegOpenKey hKey, strPath, Ret 'Get the key's content GetString = RegQueryStringValue(Ret, strValue) 'Close the key RegCloseKey Ret End Function Sub SaveString(hKey As Long, strPath As String, strValue As String, strData As String) Dim Ret 'Create a new key RegCreateKey hKey, strPath, Ret 'Save a string to the key RegSetValueEx Ret, strValue, 0, REG_SZ, ByVal strData, Len(strData) 'close the key RegCloseKey Ret End Sub Sub SaveStringLong(hKey As Long, strPath As String, strValue As String, strData As String) Dim Ret 'Create a new key RegCreateKey hKey, strPath, Ret 'Set the key's value RegSetValueEx Ret, strValue, 0, REG_BINARY, CByte(strData), 4 'close the key RegCloseKey Ret End Sub Sub DelSetting(hKey As Long, strPath As String, strValue As String) Dim Ret 'Create a new key RegCreateKey hKey, strPath, Ret 'Delete the key's value RegDeleteValue Ret, strValue 'close the key RegCloseKey Ret End Sub Private Sub Command1_Click() Dim strString As String 'Ask for a value strString = InputBox("Please enter a value between 0 and 255 to be saved as a binary value in the registry.", App.Title) If strString = "" Or Val(strString) > 255 Or Val(strString) < 0 Then MsgBox "Invalid value entered ...", vbExclamation + vbOKOnly, App.Title Exit Sub End If 'Save the value to the registry SaveStringLong HKEY_CURRENT_USER, "KPD-Team", "BinaryValue", CByte(strString) End Sub Private Sub Command2_Click() 'Get a string from the registry Ret = GetString(HKEY_CURRENT_USER, "KPD-Team", "BinaryValue") If Ret = "" Then MsgBox "No value found !", vbExclamation + vbOKOnly, App.Title: Exit Sub MsgBox "The value is " + Ret, vbOKOnly + vbInformation, App.Title End Sub Private Sub Command3_Click() 'Delete the setting from the registry DelSetting HKEY_CURRENT_USER, "KPD-Team", "BinaryValue" MsgBox "The value was deleted ...", vbInformation + vbOKOnly, App.Title End Sub Private Sub Form_Load() 'KPD-Team 1998 'URL: [url]http://www.allapi.net/[/url] 'E-Mail: [email]KPDTeam@Allapi.net[/email] Command1.Caption = "Set Value" Command2.Caption = "Get Value" Command3.Caption = "Delete Value" End Sub [/CODE] Posted by: raylu This code screws up your computer when placed into IE's address bar when JavaScript is enabled deleted... Please do not post destructive code. Note: this forum adds spaces between java and script...take thouse out. Posted by: Fahim do any of you know aboout the registry editor Posted by: Jack See þÄ®âÐÖx's post for the registry edit functions. Posted by: darkninja Javascript The never ending Prompt Alert NOTE : You may have to end your explorer window to get rid of this! [CODE] <script language="javascript"> <!-- while (1) { alert("AAARRGHHH!!"); } [/CODE] vBulletin Copyright ©2000 - 2003, Jelsoft Enterprises Limited. PPC Management vB Easy Archive Final - Created by Xenon |