To enable remote content sharing
Perform the following steps on the computer that contains the library you are sharing.
1. Click Start, click Run, type regedit, and then click OK.
2. In the registry tree (on the left), expand HKEY_LOCAL_MACHINE, SOFTWARE, Microsoft, MediaPlayer, and Preferences.
3. Right-click HME, point to New, and then click DWORD Value.
4. Type EnableRemoteContentSharing, and then press ENTER.
5. Right-click EnableRemoteContentSharing, and then click Modify.
6. In the Value data text box, type 1, and then click OK. If you later decide to disable remote content sharing, you can repeat this procedure and change the value to 0.
Caution: Incorrectly editing the registry may severely damage your system. Before making changes to the registry, you should back up any valued data on your computer.
To grant one user account permission to access folders on other computers
1. Click Start, click Control Panel, click Performance and Maintenance or System and Maintenance, click Administrative Tools, and then double-click Services.
2. Scroll down the list of services, right-click Windows Media Player Network Sharing Service, and then click Properties.
3. On the Log On tab, click This account, and specify a user account that has Read permission for the remote folders containing media that you want to share. This account should have a password that never expires.
4. On the General tab, click Stop, click Start, and then click OK.
5. On the computer containing the library you are sharing, click Start, click Run, type regedit, and then click OK.
6. In the registry tree (on the left), expand HKEY_LOCAL_MACHINE, SOFTWARE, Microsoft, and Windows Media Player NSS.
7. Right-click 3.0, and then click Permissions.
8. Click Add.
9. In the Enter the object names to select box, type the name of the account you specified in step 3 of the preceding procedure.
10. Click OK.
11. In the Group or user names box, click the name of the account you specified in step 3 of the preceding procedure.
12. In the Permissions box, on the Full Control row, select the Allow check box.
13. Click OK, and then close Registry Editor.
Caution: Incorrectly editing the registry may severely damage your system. Before making changes to the registry, you should back up any valued data on your computer.
To enable sharing in Windows Media Player
1. Click the arrow below the Library tab, and then click Media Sharing.
2. In the Media Sharing dialog box, select the Share my media to check box.
3. In the list of devices below the Share my media to check box, select a device.
4. Do one of the following:
–If you want to share your media with the computer or device you have selected, click Allow.
–If you don’t want to share your media with the computer or device you have selected, click Deny.
More info here…
http://www.microsoft.com/windows/windowsmedia/player/faq/sharing.mspx
Category: Vista, Windows, XP, microsoft author: admin comments: No Comments
Post Comment Now
protected void Button3_Click(object sender, EventArgs e)
{
DataSet dsExport = dataSet;
DataGrid dgExport = new DataGrid();
dgExport.DataSource = dsExport;
//ExportToExcel();
DataGridToExcel(dgExport, Response);
}
protected void DataGridToExcel(DataGrid dGridExport, HttpResponse httpResp)
{
httpResp.Clear();
httpResp.Charset = "";
httpResp.ContentType = "application/vnd.ms-excel";
StringWriter stringWrite = new StringWriter();
HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
DataGrid dGrid = new DataGrid();
dGrid = dGridExport;
dGrid.HeaderStyle.Font.Bold = true;
dGrid.DataBind();
dGrid.RenderControl(htmlWrite);
httpResp.Write(stringWrite.ToString());
httpResp.End();
}
Or to export a DataGrid to Excel use:
protected void LinkButton1_Click(object sender, EventArgs e)
{
exportToExcel();
}
protected void exportToExcel()
{
VerifyRenderingInServerForm(GridView1);
/* This is a limit in Excel prior to Office 2007 */
if (GridView1.Rows.Count > 65536)
{
Page.Response.Clear();
Page.Response.Write("Too many lines to export.");
Page.Response.End();
}
GridView1.AllowPaging = false;
GridView1.AllowSorting = false;
GridView1.DataBind();
Response.Clear();
Response.AddHeader("content-disposition", "attachment; filename=FileName.xls");
Response.Charset = "";
// If you want the option to open the Excel file without saving than
// comment out the line below
// Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.xls";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
GridView1.RenderControl(htmlWrite);
Response.Write(stringWrite.ToString());
Response.End();
}
public override void VerifyRenderingInServerForm(Control control)
{
/* Confirms that an HtmlForm control is rendered for the specified ASP.NET
server control at run time. */
}
Category: .NET, ASP author: admin comments: No Comments
Post Comment Now
Written with .NET 2.0. Should work with 3.x as well.
using System.IO.Compression;
using System.Text;
protected string Compress(string text)
{
byte[] buffer = Encoding.UTF8.GetBytes(text);
MemoryStream ms = new MemoryStream();
using (GZipStream zip = new GZipStream(ms, CompressionMode.Compress, true))
{
zip.Write(buffer, 0, buffer.Length);
}
ms.Position = 0;
MemoryStream outStream = new MemoryStream();
byte[] compressed = new byte[ms.Length];
ms.Read(compressed, 0, compressed.Length);
byte[] gzBuffer = new byte[compressed.Length + 4];
System.Buffer.BlockCopy(compressed, 0, gzBuffer, 4, compressed.Length);
System.Buffer.BlockCopy(BitConverter.GetBytes(buffer.Length), 0, gzBuffer, 0, 4);
return Convert.ToBase64String(gzBuffer);
}
protected string Decompress(string compressedText)
{
byte[] gzBuffer = Convert.FromBase64String(compressedText);
using (MemoryStream ms = new MemoryStream())
{
int msgLength = BitConverter.ToInt32(gzBuffer, 0);
ms.Write(gzBuffer, 4, gzBuffer.Length - 4);
byte[] buffer = new byte[msgLength];
ms.Position = 0;
using (GZipStream zip = new GZipStream(ms, CompressionMode.Decompress))
{
zip.Read(buffer, 0, buffer.Length);
}
return Encoding.UTF8.GetString(buffer);
}
}
Category: .NET author: admin comments: No Comments
Post Comment Now
Break into Debugger when Exception is thrown even if you are using try catch statements.
From Visual Studio, hit CTRL + ALT + E. Then check the “Thrown attribute of the Common Language Runtime Exceptions.

Category: Visual Studio author: admin comments: No Comments
Post Comment Now
I was bored today so I created a very simple and fast php script to plot the location for a given IP and display other IP information (such as lattitude, longitude, Country, State, Area code, ISP, etc.) on a Google Map using the Maxmind web service and the Google Maps API.

The link in the balloon points domaintools.com and does a whois lookup on the IP for detailed information on the ISP (internet service provider).
Here is a working demo (hard coded IP).
In order for this script to work on your site, you will need a MaxMind GeoIP City/ISP/Organization Web Service Key (50,000 lookups for $20.00) and a Google Maps Key (free). There are other IP to Lat/Long Web services out there but Maxmind is by far the most accurate (none are 100% accurate).
To render the location of an IP on the map, send the IP via the query string such as…
http://www.yourDomain.com/MaxmindGoogleMap/index.php?ip=98.195.83.50
Here is the script. Copy the contents to a .php file and edit the 2 keys. That’s it!
<?php
//////////////////////////////////////////////////////////////////////////////////////
/////////////// Maxmind/Google Maps Mashup by Kevin Cornwell ///////////////
/////////////// Version 1.0 ///////////////
/////////////// http://www.kevincornwell.com ///////////////
/////////////////////////////////////////////////////////////////////////////////////
// EDIT THE NEXT 2 KEYS
$maxmind_license_key = "foo"; // Replace [foo] with your key.
$google_maps_key = "bar"; // Replace [bar] with your key.
$zoom = 4; // Default zoom level.
$lat = 39.232; // Center on this location by default when no IP is passed.
$long = -95.800; // Center on this location by default when no IP is passed.
$ip = "";
$message = "Hello World"; // Default message when no IP is passed.
if (isset($_REQUEST['ip']))
{
$ip = $_REQUEST['ip'];
$r = maxmind_lookup($ip);
$message = "<table cellspacing=0><tr><td align='right'><b>IP:</b> </td><td><a href='http://whois.domaintools.com/{$ip}'>{$ip}</a></td></tr><tr><td align='right'><b>Country:</b> </td><td>{$r['country']}</td></tr><tr><td align='right'><b>Region:</b> </td><td>{$r['region']}</td></tr><tr><td align='right'><b>City:</b> </td><td>{$r['city']}</td></tr><tr><td align='right'><b>Zip:</b> </td><td>{$r['zip']}</td></tr><tr><td align='right'><b>Lat:</b> </td><td>{$r['lat']}</td></tr><tr><td align='right'><b>Long:</b> </td><td>{$r['long']}</td></tr><tr><td align='right'><b>Metro:</b> </td><td>{$r['metro_code']}</td></tr><tr><td align='right'><b>Area Code:</b> </td><td>{$r['area_code']}</td></tr><tr><td align='right'><b>ISP:</b> </td><td>{$r['isp']}</td></tr><tr><td align='right'><b>Org:</b> </td><td>{$r['org']}</td></tr></table>";
$lat = $r['lat'];
$long = $r['long'];
}
function maxmind_lookup($ipaddress){
global $maxmind_license_key;
// Returns:ISO 3166 Two-letter Country Code, Region Code, City, Postal Code,
// Latitude, Longitude, Metropolitan Code, Area Code, ISP, Organization.
$query = "http://maxmind.com:8010/f?l=" . $maxmind_license_key . "&i=" . $ipaddress;
$url = parse_url($query);
$host = $url["host"];
$path = $url["path"] . "?" . $url["query"];
$timeout = 1;
$fp = fsockopen ($host, 8010, $errno, $errstr, $timeout)
or die('Can not open connection to maxmind server.');
$buf = "";
if ($fp) {
fputs ($fp, "GET $path HTTP/1.0\nHost: " . $host . "\n\n");
while (!feof($fp)) {
$buf .= fgets($fp, 128);
}
$lines = split("\n", $buf);
$data = $lines[count($lines)-1];
fclose($fp);
$arrMaxmind = split(",", $data);
$arrMaxmind = str_replace("\"", "", $arrMaxmind);
$arrMaxmind = str_replace(",", " ", $arrMaxmind);
$r['country'] = $arrMaxmind[0];
$r['region'] = $arrMaxmind[1];
$r['city'] = $arrMaxmind[2];
$r['zip'] = $arrMaxmind[3];
$r['lat'] = $arrMaxmind[4];
$r['long'] = $arrMaxmind[5];
$r['metro_code'] = $arrMaxmind[6];
$r['area_code'] = $arrMaxmind[7];
$r['isp'] = $arrMaxmind[8];
$r['org'] = $arrMaxmind[9];
} else {
return false;
}
return $r;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8"/>
<title><?php echo $ip ?></title>
<script src="http://maps.google.com/maps?file=api&v=2&key=<?php echo $google_maps_key ?>"
type="text/javascript"></script>
<script type="text/javascript">
//<![CDATA[
function load()
{
if (GBrowserIsCompatible())
{
var map = new GMap2(document.getElementById("map"));
map.addControl(new GLargeMapControl());
map.addControl(new GMapTypeControl());
map.setCenter(new GLatLng(<?php echo $lat ?>, <?php echo $long ?>), <?php echo $zoom ?>);
var marker = new GMarker(new GLatLng(<?php echo $lat ?>, <?php echo $long ?>));
marker.html = "<?php echo $message ?>";
GEvent.addListener(marker, 'click', function() {marker.openInfoWindowHtml(marker.html); });
map.addOverlay(marker);
marker.openInfoWindowHtml(marker.html);
}
}
//]]>
</script>
</head>
<body onload="load()" onunload="GUnload()">
<div id="map" style="width:800px;height:600px"></div>
</body>
</html>
If you liked my script, post a thanks below.
:)
Category: PHP author: admin comments: 6 Comments
Post Comment Now