tag:blogger.com,1999:blog-77250302008-07-23T05:57:55.643-07:00Information TransmogrificationTeX HeXhttp://www.blogger.com/profile/14268105680697143201noreply@blogger.comBlogger60125tag:blogger.com,1999:blog-7725030.post-12203073690025381632008-06-18T03:01:00.000-07:002008-07-18T03:19:41.931-07:00Digital Photo Display FeedSurfing the Internet while searching for picture for my digital photo display, I came across two brilliant artists I would like to share with you.<br /><br />First is <a href="http://tomwilcox.deviantart.com/">Tom Wilcox at deviant ART</a> which makes stunning 3D pictures, a little bit like <a href="http://www.digitalblasphemy.com/"><span style="font-family:Trebuchet MS, Arial, Verdana, Comic Sans MS, sans-serif, serif;">Ryan Bliss </span>from Digital Blasphemy</a>. If you <a href="http://tomwilcox.deviantart.com/gallery/#_featured--3">have a look at the works of art Tom designs</a>, you will easily notice that you can look at them for hours and still notice new details you didn't saw until then. Just brilliant!<br /><br />Second is <a href="http://www.hamaddarwish.com/">Hamad Darwish</a>, a photographer that makes simply beautiful landscape photographs, the ones you stare at and won't believe this is still planet earth. Two pictures of him are even included as Wallpaper within Windows Vista, but <a href="http://www.flickr.com/photos/darwishh/sets/72157594510047657/">the entire set contains much more pictures</a>. More pictures can be found at <a href="http://www.hamaddarwish.com/gallery.html">his Gallery</a>.TeX HeXhttp://www.blogger.com/profile/14268105680697143201noreply@blogger.comtag:blogger.com,1999:blog-7725030.post-52619902978424093422008-05-07T10:48:00.001-07:002008-05-07T10:48:38.103-07:00Removing lines from the output of a command line program<p>In case you need to deal with command line programs, you sometimes face the following challenge: the programs return too much data!</p> <p>For example, Xteq Systems offers <a href="http://www.xteq.com/products/geto/">GetOSVersion</a> which returns the current Windows version you are using. However, it also contains an header line so the complete example output is this:</p> <p><font face="Courier" size="1">Xteq GetOSVersion 3.0 - Copyright (C) 2008 Xteq Systems - </font><a href="http://www.xteq.com/"><font face="Courier" size="1">http://www.xteq.com/</font></a></p> <p><font face="Courier" size="1">You are using Windows Vista (6.0) with Service Pack 1, return code is 9 <br />(PlatformID 2; Major: 6; Minor: 0; Build: 6001)</font></p> <p>Not that big deal if you (as an human) reads that but in case you want to export this data into a text file with the following command:</p> <p><font face="Courier" size="1">XQGetOsVer.exe /B >%TEMP%\result.txt</font></p> <p>you will also of course get the header line you do not want to have. However, these is an easy solution for this: the FOR command. I won't get into the details what you can do with it (a lot and if you are interested use "help FOR" inside the command shell), but to solve the current problem we can simply use these two lines:</p> <p><font face="Courier">del %TEMP%\result.txt <br /></font><font face="Courier">for /F "skip=3 delims=" %%i in ('XQGetOSVer.exe /B') do @echo %%i >>%TEMP%\result.txt </font></p> <p><font face="Courier"></font></p> <p>First, we delete the file RESULT.TXT and then we execute the FOR command with two special parameters: SKIP=3 indicates that the first three lines from the output of XQGetOSVer.exe should be skipped and thus, the header is removed. The option DELIMS= indicates that we do not have delimiters so we get every line as is. </p> <p>The part of DO indicates what we want to do with the remaining lines and use the ECHO command to write them to RESULT.TXT. We are using >> to indicate that we will append to this file (hence the DEL command first) to make sure we get all lines, not just one.</p> <p>The result is exactly what we wanted:</p> <p><font face="Courier">You are using Windows Vista (6.0) with Service Pack 1, return code is 9 <br />(PlatformID 2; Major: 6; Minor: 0; Build: 6001)</font> </p> <p>No header, just the the data.</p> TeX HeXhttp://www.blogger.com/profile/14268105680697143201noreply@blogger.comtag:blogger.com,1999:blog-7725030.post-33999704230992053412008-04-28T10:36:00.001-07:002008-04-28T10:36:38.930-07:00Moving an Intel ICH7R RAID (Intel Matrix Storage Controller) to a new main board<p>After struggling nearly four weeks with my computer and being most of the time offline, I finally managed it to build a new computer (Asus P5W, Thermaltake Shark etc.) that is running just fine. </p> <p>However, I used an RAID-1 before and the big question was: Will the new motherboard accepts this RAID or do I need to start everything from scratch? </p> <p>In general, if you plan to use an RAID-1 later on but currently have only one HD ready, it is no problem to prepare this: Switch the IDE/SATA mode in your BIOS from “Standard” or “AHCI” to “RAID” and enable the ICH7R boot ROM. Then just install Windows (F6 disk for Windows XP needed, Vista has those drivers build-in) as you would normally do. Later on, download and install the Intel Matrix Storage Manager on Windows. Once you have the second disk, simply plug it in, start Windows and start Intel Matrix Storage Manager. Inside it, just select that you want to have a RAID-1 and on the fly, an RAID-1 will be created. </p> <p>Basically, this was my idea when attaching one of the old HDs (with my RAID1) to the new motherboard. I especially selected the Asus P5W because the chipset and ICR (Intel 975X with ICH7R) where the same as on my old Shuttle SD39P2 board. </p> <p>But to my surprise, the Intel chip is much more intelligent: As soon as I attached one of the drives and booted, the ICH7R notices this one disk, showed the name I gave the RAID volume and Windows started as always. Once Windows was finished installing new components, I simply shut down and attached the second drive. Inside the Boot ROM the second drive was displayed as “Unknown” drive but once Windows started, the Matrix Storage Manager informed me that it is rebuilding my array. Two hours later, the RAID-1 was OK again and I did not lose a single file! </p> <p>Kudos to Intel for this!</p> TeX HeXhttp://www.blogger.com/profile/14268105680697143201noreply@blogger.comtag:blogger.com,1999:blog-7725030.post-34643174025495265792008-04-10T06:32:00.000-07:002008-04-30T06:40:24.778-07:00Retrieving Windows SharePoint Services user access rights from the database<span style="font-family: verdana;">I case you ever need to know which access rights a given user has on your Windows SharePoint Services (WSS) site, you may find the following SQL scripts useful.</span><br /><br /><br /><span style="font-family: verdana;">This SQL script (simply execute it against the database that has your WSS content) accepts either an email address (</span><span style="font-style: italic; font-family: verdana;">@search_email </span><span style="font-family: verdana;">= 'John.Doe@acme.org') or the Windows login name (</span><span style="font-style: italic; font-family: verdana;">@search_account</span><span style="font-family: verdana;">='ACME\JohnD').<br /></span><br /><br /><span style="font-family: verdana;">If the given user is found, it will return three tables: The data of the user as WSS sees it, the groups to which the user belongs and finally to which sites the user has access to.</span><br /><br /><br /><br /><br />DECLARE @search_email varchar(100)<br />DECLARE @search_account varchar(100)<br /><br />SET @search_email='John.Doe@acme.org<br />--SET @search_account='ACME\JohnD'<br /><br /><br />DECLARE @userid int<br /><br />-- Retrieve user ID<br />IF (@search_account is null) BEGIN<br /> select @userid=tp_ID from userinfo where tp_Email = @search_email<br />END ELSE BEGIN<br /> select @userid=tp_ID from userinfo where tp_Login = @search_account<br />END<br /><br />-- Show found user<br />SELECT '' as 'User Info',<br /> tp_ID,tp_Login,tp_Title from userinfo where tp_ID=@userid<br /><br />-- Show group membership<br />SELECT '' as 'Group membership',<br /> ID,Title,Description from groups where id in<br /> ( SELECT groupid from groupmembership where memberid=@userid )<br /> order by Title<br /><br />-- Show Access rights<br />SELECT '' as 'Access rights',<br /> Title, FulLURL from Webs where id in<br /> ( SELECT WebId FROM WebMembers WHERE (UserId = @userid) )<br /> order by Title<br />GOTeX HeXhttp://www.blogger.com/profile/14268105680697143201noreply@blogger.comtag:blogger.com,1999:blog-7725030.post-5959378550953277642008-03-15T08:24:00.000-07:002008-03-19T01:14:39.922-07:00The .NET Dataset for Stored Procedures in Visual Studio – the easy way<span style="" lang="EN-US">In case you need to call or retrieve data from a lot of stored procedures in SQL Server. You basically have two options: <o:p></o:p></span> <p class="MsoNormal" style="font-family:verdana;"><span style="" lang="EN-US">A) “Hardcore” <o:p></o:p></span></p> <p class="MsoNormal" style="font-family:verdana;"><span style="" lang="EN-US">You create your own class and define a SqlCommand object for each stored procedure manually. While doing this, tell your wife you can't see her for the next weeks<o:p></o:p></span></p> <p class="MsoNormal" style="font-family:verdana;"><span style="" lang="EN-US">B) “Lazy man”<o:p></o:p></span></p> <p class="MsoNormal" style="font-family:verdana;"><span style="" lang="EN-US">You use a dataset and let Visual Studio do the hard work. You use those generated procedure, tell your boss how many hours this took and leave early to enjoy your weekend.<o:p></o:p></span></p> <p class="MsoNormal" style="font-family:verdana;"><span style="" lang="EN-US"><o:p> </o:p></span></p> <p class="MsoNormal" style="font-family:verdana;"><span style="" lang="EN-US"><br /></span></p><p class="MsoNormal" style="font-family:verdana;"><span style="" lang="EN-US">The last option seems to be better IMHO, but the DataSet has some funny glitches that can make using it a pain. I’ll try to sort them out here.<o:p></o:p></span></p> <p class="MsoNormal" style="font-family:verdana;"><span style="" lang="EN-US"><span style="font-weight: bold;">Step 1: Create a dataset</span><o:p></o:p></span></p> <p class="MsoNormal" style="font-family:verdana;"><span style="" lang="EN-US">Easy, just right-click your project, select “Add item” and choose “Dataset”. In this case, the dataset is called “DataSetStoredProcedures”. <o:p></o:p></span></p> <p class="MsoNormal" style="font-family:verdana;"><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/_V1tbWNn9eRE/R9vrTd2TtlI/AAAAAAAAAIM/F6_6VtfgFGU/s1600-h/datasetsps1.jpg"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp1.blogger.com/_V1tbWNn9eRE/R9vrTd2TtlI/AAAAAAAAAIM/F6_6VtfgFGU/s320/datasetsps1.jpg" alt="" id="BLOGGER_PHOTO_ID_5177990916254971474" border="0" /></a></p><p class="MsoNormal" style="font-family:verdana;"><span style="" lang="EN-US"><span style="font-weight: bold;">Step 2: Move the generated dataset</span> <o:p></o:p></span></p> <p class="MsoNormal" style="font-family:verdana;"><span style="" lang="EN-US">To not clutter the project, create a new folder (right-click project, “Add” -> “New Folder”) called “DatabaseDataset”. Drag and drop “DataSetStoredProcedures.xsd” there. <o:p></o:p></span></p> <p class="MsoNormal" style="font-family:verdana;"><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp0.blogger.com/_V1tbWNn9eRE/R9vrZN2TtmI/AAAAAAAAAIU/EuHIyrR4e4w/s1600-h/datasetsps2.jpg"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp0.blogger.com/_V1tbWNn9eRE/R9vrZN2TtmI/AAAAAAAAAIU/EuHIyrR4e4w/s320/datasetsps2.jpg" alt="" id="BLOGGER_PHOTO_ID_5177991015039219298" border="0" /></a></p><p class="MsoNormal" style="font-family:verdana;"><span style="" lang="EN-US"><span style="font-weight: bold;">Step 3: Add stored procedures</span><o:p></o:p></span></p> <p class="MsoNormal" style="font-family:verdana;"><span style="" lang="EN-US">Select “View” -> “Server Explorer” to display the Server Explorer window. Right-click “Data Connections” and select “Add Connection”. Define the properties so Visual Studio can connect to the database. Open the new entry in the tree view and move to “Stored Procedures”.</span></p><p class="MsoNormal" style="font-family:verdana;"><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/_V1tbWNn9eRE/R9vrzd2TtoI/AAAAAAAAAIk/7IVXq6moShQ/s1600-h/datasetsps3.jpg"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp1.blogger.com/_V1tbWNn9eRE/R9vrzd2TtoI/AAAAAAAAAIk/7IVXq6moShQ/s320/datasetsps3.jpg" alt="" id="BLOGGER_PHOTO_ID_5177991466010785410" border="0" /></a><br /><span style="" lang="EN-US"><o:p></o:p></span></p> <p class="MsoNormal" style="font-family:verdana;"><span style="" lang="EN-US">In case you haven’t opened DataSetStoredProcedures.xsd, simply double-click it. Simply drag and drop the stored procedures you want to use to this window.<o:p></o:p></span></p> <p class="MsoNormal" style="font-family:verdana;"><span style="" lang="EN-US">You may be asked how the connection should be called that will be used to execute this stored procedure, simply choose a name that makes sense to you. Once this all has being done, the project should look something like this:</span></p><p class="MsoNormal" style="font-family:verdana;"><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/_V1tbWNn9eRE/R9vr992TtpI/AAAAAAAAAIs/Cj5dW2dp36A/s1600-h/datasetsps4.jpg"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp3.blogger.com/_V1tbWNn9eRE/R9vr992TtpI/AAAAAAAAAIs/Cj5dW2dp36A/s320/datasetsps4.jpg" alt="" id="BLOGGER_PHOTO_ID_5177991646399411858" border="0" /></a><br /><span style="" lang="EN-US"><o:p></o:p></span></p> <p class="MsoNormal" style="font-family:verdana;"><span style="" lang="EN-US"><span style="font-weight: bold;">Step 4: Check the stored procedures</span><o:p></o:p></span></p> <p class="MsoNormal" face="verdana"><span style="" lang="EN-US">At any time, you can simply click on a stored procedure, open the properties window and click on the “…” button for the Parameters:</span></p><p class="MsoNormal" face="verdana"><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/_V1tbWNn9eRE/R9vsE92TtqI/AAAAAAAAAI0/3QUJHA5lw0k/s1600-h/datasetsps5.jpg"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp3.blogger.com/_V1tbWNn9eRE/R9vsE92TtqI/AAAAAAAAAI0/3QUJHA5lw0k/s320/datasetsps5.jpg" alt="" id="BLOGGER_PHOTO_ID_5177991766658496162" border="0" /></a><br /><span style="" lang="EN-US"><o:p></o:p></span></p> <p class="MsoNormal" face="verdana"><span style="" lang="EN-US">You should do this simply because sometimes the generation is not done right. For example, in this project there is a user defined function (yes, you can also add UDFs) called “fncLTC2UTC” that return an SQL Server datetime value. However, the dataset converted this to “Object”. By using the parameters collection, you can simply change the value of @RETURN from object to DateTime.<o:p></o:p></span></p> <p class="MsoNormal" face="verdana"><span style="" lang="EN-US"><span style="font-weight: bold;">Step 5: The glitches, Part I</span><o:p></o:p></span></p> <p class="MsoNormal" face="verdana"><span style="" lang="EN-US">By using the object browser, you can have a look at the namespace layout:</span></p><p class="MsoNormal" style="font-family: verdana;"><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp0.blogger.com/_V1tbWNn9eRE/R90aat2TtsI/AAAAAAAAAJE/oMdx0DBU4hE/s1600-h/datasetsps6.jpg"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp0.blogger.com/_V1tbWNn9eRE/R90aat2TtsI/AAAAAAAAAJE/oMdx0DBU4hE/s400/datasetsps6.jpg" alt="" id="BLOGGER_PHOTO_ID_5178324192832239298" border="0" /></a><br /><span style="" lang="EN-US"><o:p></o:p></span></p> <p class="MsoNormal" style="font-family: verdana;"><span style="" lang="EN-US">The project where we have added all this is called “x.server”. Because we have created a subfolder to put the dataset in, the namespace of the dataset has become “x.server.DatabaseDataset”. Beside this, the stored procedures where create in a sub object “QueriesTableAdapter” that has the namespace “x.server.DatabaseDataSet.DataSetStoredProceduresTableAdapters”:<o:p></o:p></span></p> <p class="MsoNormal" style="font-family: verdana;"><span style="" lang="EN-US">Now this is a hell of a namespace we need to add it before we can call a stored procedure:</span></p><p class="MsoNormal" style="font-family: verdana;"><br /><span style="" lang="EN-US"><o:p></o:p></span></p> <p class="MsoNormal" style="font-family: verdana;"><span style="line-height: 115%;font-size:10;color:blue;" lang="EN-US" >using</span><span style="line-height: 115%;font-size:10;" lang="EN-US" > x.server.DatabaseDataset.DataSetStoredProceduresTableAdapters;<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;font-family:verdana;"><span style=";font-size:10;color:blue;" lang="EN-US" >class</span><span lang="EN-US" style="font-size:10;"> <span style="color: rgb(43, 145, 175);">JustTesting<o:p></o:p></span><br /><span style=""> </span>{<o:p></o:p><br /><span style=""> </span><span style="color:blue;">public</span> <span style="color:blue;">static</span> <span style="color:blue;">void</span> Test1()<o:p></o:p><br /><span style=""> </span>{<o:p></o:p><br /><span style=""> </span><span style="color: rgb(43, 145, 175);">QueriesTableAdapter</span> qta = <span style="color:blue;">new</span> <span style="color: rgb(43, 145, 175);">QueriesTableAdapter</span>();<o:p></o:p><br /><span style=""> </span>qta.procClientAuthentication_GetLoginData(…<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;font-family:verdana;"><span lang="EN-US" style="font-size:10;"><o:p> </o:p></span><span style="" lang="EN-US"><o:p> </o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;font-family:verdana;"><span style="" lang="EN-US"><span style="font-weight: bold;"><br /></span></span></p><p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;font-family:verdana;"><span style="" lang="EN-US"><span style="font-weight: bold;">Step 6: The glitches, Part II</span><o:p></o:p><br /><br />Beside this namespace glitch, there is another one: By default, the dataset insists on using the connection string that each stored procedure has attached to (Properties viewer) and you can not to change this. In case you do not want to have the database connection inside app.config this would normally stop the use of the dataset.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;font-family:verdana;"><span style="" lang="EN-US"><o:p> </o:p><br /><span style="font-weight: bold;">Step 7: The solution</span><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;font-family:verdana;"><span style="" lang="EN-US"><o:p></o:p>However, both glitches can easily be fixed. Within your normal namespace (e.g. “x.server”) simply define a class like this:<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;font-family:verdana;"><span style=";font-size:10;color:blue;" lang="EN-US" ><br /></span></p><p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;font-family:verdana;"><span style=";font-size:10;color:blue;" lang="EN-US" >using</span><span lang="EN-US" style="font-size:10;"> System;<o:p></o:p></span><br /><span style=";font-size:10;color:blue;" lang="EN-US" >using</span><span lang="EN-US" style="font-size:10;"> System.Collections.Generic;<o:p></o:p></span><br /><span style=";font-size:10;color:blue;" lang="EN-US" >using</span><span lang="EN-US" style="font-size:10;"> System.Text;<o:p></o:p></span><br /><span style=";font-size:10;color:blue;" lang="EN-US" >using</span><span lang="EN-US" style="font-size:10;"> System.Data;<o:p></o:p></span><br /><span style=";font-size:10;color:blue;" lang="EN-US" >using</span><span lang="EN-US" style="font-size:10;"> x.server.DatabaseDataset.DataSetStoredProceduresTableAdapters;<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;font-family:verdana;"><span lang="EN-US" style="font-size:10;"><o:p></o:p></span><span style=";font-size:10;color:blue;" lang="EN-US" >namespace</span><span lang="EN-US" style="font-size:10;"> x.server<o:p></o:p><br />{<o:p></o:p><br /><span style=""> </span><span style="color:gray;">///</span><span style="color:green;"> </span><span style="color:gray;"><summary><o:p></o:p></summary></span><br /><span style=""> </span><span style="color:gray;">///</span><span style="color:green;"> Shortcut class to all database stored procedures (procXXX). <o:p></o:p></span><br /><span style=""> </span><span style="color:gray;">///</span><span style="color:green;"> </span><span style="color:gray;"><o:p></o:p></span><br /><span style=""> </span><span style="color:blue;">public</span> <span style="color:blue;">class</span> <span style="color: rgb(43, 145, 175);">DatabaseProcs</span>:<span style="color: rgb(43, 145, 175);">QueriesTableAdapter<o:p></o:p></span><br /><span style=""> </span>{<o:p></o:p><br /><span style=""> </span><span style="color:blue;">public</span> DatabaseProcs()<o:p></o:p><br /><span style=""> </span>: <span style="color:blue;">base</span>()<o:p></o:p><br /><span style=""> </span>{<o:p></o:p><br /><span style=""> </span><span style="color:blue;">string</span> sConnString = <span style="color: rgb(43, 145, 175);">“Your Connection string here”;</span><o:p> </o:p><br /><span style=""> </span><span style="color:blue;">foreach</span> (<span style="color: rgb(43, 145, 175);">IDbCommand</span> cmd <span style="color:blue;">in</span> CommandCollection)<o:p></o:p><br /><span style=""> </span>{<o:p></o:p><br /><span style=""> </span>cmd.Connection.ConnectionString = sConnString;<o:p></o:p><br /><span style=""> </span>}<o:p></o:p><br /><span style=""> </span>}<o:p> </o:p><br /><span style=""> </span>}<o:p></o:p><br />}</span></p><p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;font-family:verdana;"><br /><span lang="EN-US" style="font-size:10;"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;font-family:verdana;"><span lang="EN-US" style="font-size:10;"><o:p> </o:p></span><br /><span style="" lang="EN-US">This class solves the two glitches: You need to reference the namespace only in this class (DatabaseProcs), all other objects that will use this class do not need to do it.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;font-family:verdana;"><span style="" lang="EN-US"><o:p></o:p>Second, DatabaseProcs is derived from QueriesTableAdapter so it can use the protected property “ConnectionString” and change it to anything you want.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;font-family:verdana;"><span style="" lang="EN-US"><o:p></o:p>With this class in between, calling a stored procedure is quite simple:<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;font-family:verdana;"><span style=";font-size:10;color:blue;" lang="EN-US" ><br /></span></p><p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;font-family:verdana;"><span style=";font-size:10;color:blue;" lang="EN-US" >using</span><span lang="EN-US" style="font-size:10;"> System;<o:p></o:p></span><br /><span style=";font-size:10;color:blue;" lang="EN-US" >using</span><span lang="EN-US" style="font-size:10;"> System.Collections.Generic;<o:p></o:p></span><br /><span style=";font-size:10;color:blue;" lang="EN-US" >using</span><span lang="EN-US" style="font-size:10;"> System.Text;<o:p> </o:p></span><br /><span style=";font-size:10;color:blue;" lang="EN-US" ></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;font-family:verdana;"><span style=";font-size:10;color:blue;" lang="EN-US" >namespace</span><span lang="EN-US" style="font-size:10;"> x.server<o:p></o:p><br />{<o:p></o:p><br /><span style=""> </span><span style="color:blue;">class</span> <span style="color: rgb(43, 145, 175);">JustTesting<o:p></o:p></span><br /><span style=""> </span>{<o:p></o:p><br /><span style=""> </span><span style="color:blue;">public</span> <span style="color:blue;">static</span> <span style="color:blue;">void</span> Test1()<o:p></o:p><br /><span style=""> </span>{<o:p></o:p><br /><span style=""> </span><span style="color: rgb(43, 145, 175);">DatabaseProcs</span> procs = <span style="color:blue;">new</span> <span style="color: rgb(43, 145, 175);">DatabaseProcs</span>();<o:p></o:p></span></p><p class="MsoNormal" style="margin: 0cm 0cm 0.0001pt 70.8pt; line-height: normal;font-family:verdana;"><span lang="EN-US" style="font-size:10;">procs.procClientAuthentication_GetLoginData(…</span></p><br /><p class="MsoNormal" style="margin: 0cm 0cm 0.0001pt 70.8pt; line-height: normal; font-family: verdana;"><br /></p><p class="MsoNormal" style="margin: 0cm 0cm 0.0001pt 70.8pt; line-height: normal;font-family:verdana;"><br /><span lang="EN-US" style="font-size:10;"><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;font-family:verdana;"><span style="" lang="EN-US">No more stupid namespaces and you your custom connection string is also set.<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;font-family:verdana;"><span style="" lang="EN-US"><o:p> </o:p><br /><span style="font-weight: bold;">Note</span><o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;font-family:verdana;"><span style="" lang="EN-US">The generated class will also leave the connection in the same state as it was before. This means, when you use the class DatabaseProcs (aka “QueriesTableAdapter”) like this, a connection will be opened when you execute it and closed right after that. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;font-family:verdana;"><span style="" lang="EN-US"><o:p></o:p>This might lead to a performance issue if you do not use connection pooling. To enable connection pooling simply use a connection string like this:<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;font-family:verdana;"><span style="" lang="EN-US"><o:p></o:p><span style="font-family:courier new;"><br /></span></span></p><p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;font-family:verdana;"><span style="" lang="EN-US"><span style="font-family:courier new;">Data Source=(local)\SQLEXPRESS;Initial Catalog=X;Integrated Security=True;Pooling=True;Min Pool Size=0;Max Pool Size=5;Application Name=MyApp</span><o:p style="font-family: courier new;"></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;font-family:verdana;"><span style="" lang="EN-US"><o:p style="font-family: courier new;"></o:p><br /></span></p><p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;font-family:verdana;"><span style="" lang="EN-US">If pooling is activated, a Connection.Close() does not actually close the connection but instead it will put the connection in the pool and reuse it when the next request to Connection.Open() comes in. <o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; line-height: normal;font-family:verdana;"><span style="" lang="EN-US"><o:p> </o:p><br />Enjoy!<o:p></o:p></span></p>TeX HeXhttp://www.blogger.com/profile/14268105680697143201noreply@blogger.comtag:blogger.com,1999:blog-7725030.post-67901022012496241162008-03-05T03:24:00.000-08:002008-03-05T03:26:49.643-08:00Java EmbargoOkay, I know Germany and the USA had their problems in the past. But this is going too far...<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/_V1tbWNn9eRE/R86DRbHikGI/AAAAAAAAAIE/ymPVo-wybJM/s1600-h/JavaEmargo.png"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp3.blogger.com/_V1tbWNn9eRE/R86DRbHikGI/AAAAAAAAAIE/ymPVo-wybJM/s320/JavaEmargo.png" alt="" id="BLOGGER_PHOTO_ID_5174217357255676002" border="0" /></a>TeX HeXhttp://www.blogger.com/profile/14268105680697143201noreply@blogger.comtag:blogger.com,1999:blog-7725030.post-1477019104907649392008-02-26T02:42:00.000-08:002008-04-30T06:44:36.481-07:00Backup Exec 12: Error "The Backup Exec Server Service detected a schema version mismatch."<p class="MsoNormal" face="verdana">I just tried to update our Backup Exec 11d SP1 to Backup Exec 12 and although all pre-checks were okay and the installation did also not issue any errors, BE didn't started. Checked the event log and the following events were logged:</p> <p style="font-family: courier new;" face="courier new" class="MsoNormal">The Backup Exec Server Service detected a schema version mismatch.</p> <p class="MsoNormal" face="verdana"><o:p>and<br /></o:p></p> <p class="MsoNormal" style="font-family: verdana;"><span style="font-family:courier new;">The Backup Exec Server Service did not start. An internal error (-536813108) occurred in object 1.</span><br /><o:p></o:p><br />Oh, I really love database schema errors. According to the Symantec support website (<a href="http://seer.entsupport.symantec.com/docs/283038.htm">http://seer.entsupport.symantec.com/docs/283038.htm</a> or <a href="http://seer.entsupport.symantec.com/docs/254014.htm">http://seer.entsupport.symantec.com/docs/254014.htm</a>) you need to recreate the entire database if this error happens which means you need to recreate everything from scratch! Thanks for nothing buddy!</p> <p class="MsoNormal" style="font-family: verdana;">Using SQL Server Profiler, I was able to figure out what the problem was. BE uses two tables as schema reference: <span style="font-family:courier new;">ControlInfo </span>and <span style="font-family:courier new;">Version </span>(you can simply install the SQL Server Mngmt Studio Express and issue an "select * from …" for these two). In this case here, ControlInfo was okay (Version 12.0) but Version still had 11 for some components listed.</p> <p style="font-family: verdana;" class="MsoNormal"><o:p> </o:p><br />There are two SQL files you need to execute against your BEDB database (using Mngmt Studio Express for example):</p> <p style="font-family: courier new;" face="courier new" class="MsoNormal">C:\Program Files\Symantec\Backup Exec\dbupgrade11.5.sql</p> <p style="font-family: verdana;" class="MsoNormal">If there are any errors, you may ignore them.</p> <p style="font-family: verdana;" class="MsoNormal"><o:p></o:p><br />Once this has run, run</p> <p face="courier new" class="MsoNormal">C:\Program Files\Symantec\Backup Exec\dbupgrade11.5-viewandsp.sql</p> <p style="font-family: verdana;" class="MsoNormal">Inside this file, there might be a problem with the following command:</p> <p face="courier new" class="MsoNormal">-- sync with bedb.sql version, 1.644</p> <p style="font-family: courier new;" class="MsoNormal">ALTER TABLE [dbo].[Alert] ADD </p> <p style="font-family: courier new;" class="MsoNormal"><span style=""> </span>CONSTRAINT [DF_Alert_UMI] DEFAULT (N'') FOR [UMI]</p> <p style="font-family: courier new;" class="MsoNormal">GO</p> <p style="font-family: verdana;" class="MsoNormal"><o:p> </o:p><br />Simply delete these lines and the script will run to the end. Restarting Backup Exec should now show that BE does no longer throw an schema mismatch error.</p> <p style="font-family: verdana;" class="MsoNormal"><o:p><br /></o:p></p> <p style="font-family: verdana;" class="MsoNormal">Enjoy!<br /><!--[if !supportLineBreakNewLine]--><br /><!--[endif]--></p>TeX HeXhttp://www.blogger.com/profile/14268105680697143201noreply@blogger.comtag:blogger.com,1999:blog-7725030.post-909746907985174142008-02-18T07:05:00.000-08:002008-02-21T02:06:43.565-08:00Setting the right font for a Windows Forms application<p class="MsoNormal"><span style="" lang="EN-US">If you create a new form in Visual Studio, the default font will always be "Microsoft Sans Serif" although you should use a font that depends on the Windows version you are running on. For Windows 2000, XP, Server 2003 you should use "Tahoma" for <st1:place st="on">Vista</st1:place> and above it should be "<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/uxguide/uxguide/Resources/WhatsNewInVista/fonts.asp">Segoe UI</a>". In any case, do not use "MS Sans Serif".<o:p></o:p></span></p> <p class="MsoNormal"><span style="" lang="EN-US">Unfortunately, there is no simple property available so the form uses the correct font automatically. <a href="http://brh.numbera.com/blog/index.php/2007/04/11/setting-the-correct-default-font-in-net-windows-forms-apps/">Benjamin Hollis has a blog entry</a> about this problem already and his code is quite simple and works quite well. <o:p></o:p></span></p> <p class="MsoNormal"><span style="" lang="EN-US">It just does not take into account if a form contains other, specialized fonts or if the fonts used have special styles (Underlined, Italics etc.) applied. I have tweaked his code a little bit.. ähm.. a lot actually and this is the result: FormFontFixer.<o:p></o:p></span></p><span style="font-weight: bold;">UPDATE:</span> The code is now licensed under a BSD license (see below)<br /><br /><pre><br />//Original idea and code (3 lines :-) by Benjamin Hollis: http://brh.numbera.com/blog/index.php/2007/04/11/setting-the-correct-default-font-in-net-windows-forms-apps/<br />//Copyright (C) TeX HeX of Xteq Systems: http://texhex.blogspot.com/ and http://www.texhex.info/<br />public static class FormFontFixer<br />{<br />//This list contains the fonts we want to replace.<br />static readonly List<string> FontReplaceList<br /> = new List<string>( new string[] { "Microsoft Sans Serif", "Tahoma" } );<br /><br /><br />static Font _DefaultFont;<br />static bool _CanFixFonts;<br /><br /><br />static FormFontFixer()<br />{<br /> //Basically the font name we want to use should be easy to choose by using the SystemFonts class. However, this class<br /> //is hard-coded (!!) and doesn't seem to work right. On XP, it will mostly return "Microsoft Sans Serif" except<br /> //for the DialogFont property (=Tahoma) but on Vista, this class will return "Tahoma" instead of "SegoiUI" for this property!<br /><br /> //Therefore we will do the following: If we are running on a OS below XP, we will exit because the only font available<br /> //will be MS Sans Serif. On XP, we gonna use "Tahoma", and any other OS we will use the value of the MessageBoxFont<br /> //property because this seems to be set correctly on Vista an above.<br /><br /> if (Environment.OSVersion.Platform==PlatformID.Win32Windows)<br /> {<br /> //95, 98 and other crap<br /> _CanFixFonts = false;<br /> return;<br /> }<br /><br /> if (Environment.OSVersion.Version.Major < 5)<br /> {<br /> //Windows NT<br /> _CanFixFonts = false;<br /> return;<br /> }<br /><br /> if (Environment.OSVersion.Version.Major < 6)<br /> {<br /> //Windows 2000 (5.0), Windows XP (5.1), Windows Server 2003 and XP Pro x64 Edtion v2003 (5.2)<br /> _CanFixFonts = true;<br /> _DefaultFont = SystemFonts.DialogFont; //Tahoma hopefully<br /> }<br /> else<br /> {<br /> //Vista and above<br /> _CanFixFonts = true;<br /> _DefaultFont = SystemFonts.MessageBoxFont; //should be SegoiUI<br /> }<br />}<br /><br />public static void Fix(Form form)<br />{<br /> //If we can't fix the font, exit<br /> if (_CanFixFonts == false)<br /> {<br /> return;<br /> }<br /><br /><br /> //Now start with the real work...<br /> foreach (Control c in form.Controls)<br /> {<br /> //only replace fonts that use one the "system fonts" we have declared<br /> if (FontReplaceList.IndexOf(c.Font.Name) > -1)<br /> { <br /> //Now check the size, when the size is 9 or below it's the default font size and we do not keep the size since<br /> //SegoiUI has a complete different spacing (and thus size) than MS SansS or Tahoma.<br /> <br /> //Also check if there are any styles applied on the font (e.g. Italic) which we need to apply to the new<br /> //font as well.<br /><br /> bool bUseDefaultSize = true;<br /> bool bUseDefaultStyle = true;<br /><br /> //is this a special size?<br /> if ((c.Font.Size <= 8) || (c.Font.Size >= 9))<br /> {<br /> bUseDefaultSize = false;<br /> }<br /><br /> //are any special styles (bold, italic etc.) applied to this font?<br /> if ( (c.Font.Italic == true) ||<br /> (c.Font.Strikeout == true) ||<br /> (c.Font.Underline == true) ||<br /> (c.Font.Bold == true))<br /> {<br /> bUseDefaultStyle = false;<br /> }<br /><br /> //if everything is set to defaults, we can use our prepared font right away<br /> if ((bUseDefaultSize == true) && (bUseDefaultStyle == true))<br /> {<br /> c.Font = _DefaultFont;<br /> }<br /> else<br /> {<br /> //There are non default properties set so<br /> //there is some work we need to do...<br /><br /> <br /> //Restrive custom font style<br /> FontStyle Style = FontStyle.Regular; <br /> if (bUseDefaultStyle == false)<br /> {<br /> if (c.Font.Italic) { <br /> Style = Style | FontStyle.Italic;<br /> }<br /> if (c.Font.Strikeout) {<br /> Style = Style | FontStyle.Strikeout;<br /> }<br /> if (c.Font.Underline) {<br /> Style = Style | FontStyle.Underline;<br /> }<br /> if (c.Font.Bold){<br /> Style = Style | FontStyle.Bold;<br /> }<br /> }<br /><br /> //Retrive custom size<br /> float fFontSize = _DefaultFont.SizeInPoints;<br /> if (bUseDefaultSize == false)<br /> {<br /> fFontSize = c.Font.SizeInPoints;<br /><br /> }<br /><br /> //Finally apply this font...<br /> Font font = new Font(_DefaultFont.Name, fFontSize, Style, GraphicsUnit.Point);<br /> c.Font = font;<br /><br /> } <br /> }<br /> }<br /><br />}<br />}<br /><span style="font-style: italic;font-size:85%;" ><br /><br />Copyright (c) 2008, TeX HeX (http://www.texhex.info/)<br /><br />All rights reserved.<br /><br />Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:<br /><br /> * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.<br /> * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.<br /> * Neither the name of the Xteq Systems (http://www.xteq.com/) nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.<br /><br />THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS<br />"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT<br />LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR<br />A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR<br />CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,<br />EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,<br />PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR<br />PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF<br />LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING<br />NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS<br />SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.<br /></span></pre>TeX HeXhttp://www.blogger.com/profile/14268105680697143201noreply@blogger.comtag:blogger.com,1999:blog-7725030.post-57956303689665389652008-02-16T04:15:00.000-08:002008-02-16T04:24:38.511-08:00Security Neutral Mutex<w:sdt style="font-family: verdana;" contentlocked="t" sdtgroup="t" id="89512093"><span style=";font-size:78%;" ><w:sdtpr></w:sdtpr><w:sdt xpath="/ns0:BlogPostInfo/ns0:PostTitle" docpart="4B7B9F27E81A4AF68A6B4E8702BC9B50" text="t" storeitemid="X_F5AD2B82-50D2-4E60-B4B1-793D41D1531F" title="Titel des Beitrags" id="89512082"></w:sdt></span></w:sdt><span style="font-family: verdana;" lang="EN-US">We have just completed a project where we had a very “strange” requirement: A Mutex that is normally created by a service but might also be changed or created by the application running as a limited user. Before .NET, we would simply have created a Mutex with a NULL DACL but this is no longer possible because the Mutex Class will actively prevent this. <o:p></o:p></span> <p style="font-family: verdana;" class="MsoNormal"><span style="" lang="EN-US">Fortunately, we found a blog post where the author simply created a Mutex and give EVERYONE full rights on the Mutex which is basically the same as a NULL DACL: <a href="http://rdn-consulting.com/blog/2007/09/14/more-on-using-a-named-mutex-in-vista/">http://rdn-consulting.com/blog/2007/09/14/more-on-using-a-named-mutex-in-vista/</a><o:p></o:p></span></p> <p style="font-family: verdana;" class="MsoNormal"><span style="" lang="EN-US">We changed the code a little bit and here is the result:<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; font-family: verdana;"><span style=";font-size:10;" lang="EN-US" ><span style=""> </span><span style="font-size:85%;color:green;"><br /></span></span></p><p class="MsoNormal" style="margin-bottom: 0.0001pt; font-family: verdana;"><span style=";font-size:10;" lang="EN-US" ><span style="font-size:85%;color:green;">//Original Code: http://rdn-consulting.com/blog/2007/08/20/kernel-object-namespace-and-vista/<o:p></o:p></span></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; font-family: verdana;"><span style=";font-size:85%;" lang="EN-US" ><span style=""> </span><span style="color:blue;">public</span> <span style="color:blue;">static</span> <span style="color: rgb(43, 145, 175);">Mutex</span> Create(<span style="color:blue;">string</span> Name)<o:p></o:p><br /><span style=""> </span>{<o:p></o:p><br /><span style=""> </span><span style="color:blue;">bool</span> bTrash;<o:p></o:p><br /><span style=""> </span><span style="color:blue;">return</span> Create(Name, <span style="color:blue;">out</span> bTrash);<o:p></o:p><br /><span style=""> </span>}<o:p> </o:p><br /><span style=""></span></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; font-family: verdana;"><span style=";font-size:85%;" lang="EN-US" ><span style=""> </span><span style="color:blue;">public</span> <span style="color:blue;">static</span> <span style="color: rgb(43, 145, 175);">Mutex</span> Create(<span style="color:blue;">string</span> Name, <span style="color:blue;">out</span> <span style="color:blue;">bool</span> MutexWasCreated)<o:p></o:p><br /><span style=""> </span>{<o:p></o:p><br /><span style=""> </span><span style="color:green;">//Always use global scope<o:p></o:p></span><br /><span style=""> </span><span style="color:blue;">string</span> name = <span style="color: rgb(163, 21, 21);">@"Global\"</span> + Name;<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; font-family: verdana;"><span style=";font-size:85%;" lang="EN-US" ><o:p></o:p><span style=""> </span><span style="color: rgb(43, 145, 175);">MutexSecurity</span> sec = <span style="color:blue;">new</span> <span style="color: rgb(43, 145, 175);">MutexSecurity</span>();<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; font-family: verdana;"><span style=";font-size:85%;" lang="EN-US" ><o:p> </o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; font-family: verdana;"><span style=";font-size:85%;" lang="EN-US" ><span style=""> </span><span style="color: rgb(43, 145, 175);">MutexAccessRule</span> secRule = <span style="color:blue;">new</span> <span style="color: rgb(43, 145, 175);">MutexAccessRule</span>(<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; font-family: verdana;"><span style=";font-size:85%;" lang="EN-US" ><span style=""> </span><span style="color:blue;">new</span> <span style="color: rgb(43, 145, 175);">SecurityIdentifier</span>(<span style="color: rgb(43, 145, 175);">WellKnownSidType</span>.WorldSid, <span style="color:blue;">null</span>),<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; font-family: verdana;"><span style=";font-size:85%;" lang="EN-US" ><span style=""> </span><span style="color: rgb(43, 145, 175);">MutexRights</span>.FullControl, <span style="color: rgb(43, 145, 175);">AccessControlType</span>.Allow);<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; font-family: verdana;"><span style=";font-size:85%;" lang="EN-US" ><o:p> </o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; font-family: verdana;"><span style=";font-size:85%;" lang="EN-US" ><span style=""> </span>sec.AddAccessRule(secRule);<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; font-family: verdana;"><span style=";font-size:85%;" lang="EN-US" ><o:p> </o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; font-family: verdana;"><span style=";font-size:85%;" lang="EN-US" ><span style=""> </span><span style="color:blue;">bool</span> mutexWasCreated;<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; font-family: verdana;"><span style=";font-size:85%;" lang="EN-US" ><span style=""> </span><span style="color: rgb(43, 145, 175);">Mutex</span> m = <span style="color:blue;">new</span> <span style="color: rgb(43, 145, 175);">Mutex</span>(<span style="color:blue;">false</span>, name, <span style="color:blue;">out</span> mutexWasCreated, sec);<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; font-family: verdana;"><span style=";font-size:85%;" lang="EN-US" ><o:p> </o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; font-family: verdana;"><span style=";font-size:85%;" lang="EN-US" ><span style=""> </span></span><span style=";font-size:85%;" >MutexWasCreated = mutexWasCreated;<o:p></o:p></span></p> <p class="MsoNormal" style="margin-bottom: 0.0001pt; font-family: verdana;"><span style=";font-size:85%;" ><span style=""> </span><span style="color:blue;">return</span> m;<o:p></o:p></span></p> <p style="font-family: verdana;" class="MsoNormal"><span style=";font-size:85%;" ><span style=""> </span>}</span></p>TeX HeXhttp://www.blogger.com/profile/14268105680697143201noreply@blogger.comtag:blogger.com,1999:blog-7725030.post-76829364839331860162008-02-08T10:48:00.000-08:002008-02-08T10:51:08.463-08:00XQGetOSVer 3.0 availableWe have just released <a href="http://www.xteq.com/products/geto/">Xteq Systems GetOSVersion 3.0</a> (XQGetOSVer).<br /><br />XQGetOSVer returns a number for each detected OS (Windows 95 up to Windows Server 2008) and can therefore easily be used for batch files where you want to execute special commands depending on the OS in use.TeX HeXhttp://www.blogger.com/profile/14268105680697143201noreply@blogger.comtag:blogger.com,1999:blog-7725030.post-49293588081400866712008-01-31T13:00:00.001-08:002008-01-31T13:17:29.143-08:00WiX Toolkit (Windows Installer) Custom actions and conditionsNormally, for setup projects I use <a href="http://www.jrsoftware.org/isinfo.php">InnoSetup from Jordan Russel</a> which is, put simple, the best setup creator you will find.<br /><br />However, for a project I was forced to produce a Windows Installer package and used the WiX toolkit for it. Basically, after several dead-ends I was finally completely stuck. I simply wanted to have Windows Installer executing a custom action on <span style="font-weight: bold;">every </span>install of the application, regardless if it's already installed or not. If the application is being removed, my custom action shouldn't be executed.<br /><br />By default, you would simply use the condition "NOT Installed" which means: If the application is not installed, execute it. Else, leave it alone. But as I said I wanted it to be execute every time somebody issues a command like <span style="font-style: italic;">MSIEXEX /I MyProduct.msi</span>. The default condition would evaluate to FALSE (since the application is already installed) and thus, the custom action isn't started. Of course, you could pass /fa to MSIEXEC.exe but I feared this would be forgotten and thus I would get more "Nothing is working here calls".<br /><br />After searching and testing for nearly two hours (and found an <a href="http://blog.wharton.com.au/2007/08/wix-installing-windows-nt-user-defined.html">excellent post about custom actions and properties</a> from Jeff Wharton) I was able to find the correct solution:<br /><pre><br /><custom action="LaunchExe" after="InstallInitialize">NOT (REMOVE="ALL")</custom><br /></pre><br />This simply means: If the application is NOT being removed, execute the custom action.<br /><br />If you know how, it's simple.<br /><br /></span>TeX HeXhttp://www.blogger.com/profile/14268105680697143201noreply@blogger.comtag:blogger.com,1999:blog-7725030.post-91645342353871981252008-01-24T04:51:00.000-08:002008-01-25T00:25:24.446-08:00Using caspol.exe to change .NET security policy - done rightMaybe you know CASPOL.exe to modify or add your own security policy for the .NET Framework.<br /><br />Most examples you will find on the internet will simply add a code group to the configuration and most people use it this way: Upon each installation, CASPOL.EXE is exeucted.<br /><br />What most people not realize is that CASPOL does <span style="font-weight: bold;">not </span>remove the old group when adding a new one with the same name. See this screenshot:<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp2.blogger.com/_V1tbWNn9eRE/R5iKC6zNaNI/AAAAAAAAAHU/ziHcV2lN1So/s1600-h/caspol-groups.JPG"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp2.blogger.com/_V1tbWNn9eRE/R5iKC6zNaNI/AAAAAAAAAHU/ziHcV2lN1So/s320/caspol-groups.JPG" alt="" id="BLOGGER_PHOTO_ID_5159025155901319378" border="0" /></a>This is no broken installation, for .NET everything is fine even if 100+ groups with the same name would exist. However, for the user this looks like a bug so he will call support. To make things even worse: When you have changed the group membership of your custom group later on you will end up with two groups with completely different membership conditions.<br /><br />To avoid this, I developed the following batch file that you can use and customize. The basic trick is to first list all available groups and if the script finds one that has the same name, it will be deleted.<br /><br />For more information about CasPol.exe, see <a href="http://msdn2.microsoft.com/en-us/library/cb6t8dtz.aspx">MSDN. </a><br /><br />Enjoy!<br /><br /><pre><br />@echo off<br />Rem .NET Framework 2.0 CasPol.exe batch by TeX HeX<br />Rem http://texhex.blogspot.com<br />Rem Version 1.0<br /> <br />Rem Set this to the name of the group you want to create<br />SET GROUP=Testing123<br />Rem Set this to the description your group should have<br />SET GROUPDESC=Just testing group <br /><br />SET CASPOL=%WINDIR%\Microsoft.Net\Framework\v2.0.50727\caspol.exe<br />SET ERRLVL=9<br /><br />echo ---- Setting prompt off ----<br />%caspol% -polchgprompt off <br /><br />Rem Check if this group exists already<br />echo ---- Check group existence ----<br />%caspol% -m -ld|find /C /I "%GROUP%"<br />IF NOT ERRORLEVEL 1 GOTO DELETE_GROUP<br />GOTO CREATE_GROUP<br /><br /><br />Rem Deleting old group (two times to make sure that we do not have one left over)<br />:delete_group<br />echo ---- Removing old group ----<br />CASPOL% -m -remgroup "%GROUP%"<br />CASPOL% -m -remgroup "%GROUP%" >NUL<br /><br /><br />:create_group<br />echo ---- Creating group ----<br />REM %CASPOL% -m -addgroup All_Code -url "\*" -zone MyComputer FullTrust -name "%GROUP%" <br />REM %CASPOL% -m -addgroup All_Code -strong -file c:\arg.dll -noname -noversion FullTrust -name "%GROUP%" -description "%GROUPDESC%"<br /><br />%CASPOL% -m -addgroup All_Code -zone MyComputer FullTrust -name "%GROUP%" -description "%GROUPDESC%"<br />SET ERRLVL=%ERRORLEVEL%<br /><br />echo Result is %ERRLVL%<br /><br />Rem Patch prompting again<br />echo ---- Setting prompt on ----<br />%caspol% -polchgprompt on<br /><br /><br /><br />Rem Now check the result<br />IF %ERRLVL% EQU 0 (<br /> echo "All fine!"<br /> exit 0<br />) ELSE (<br /> echo "Error!"<br /> exit -1<br />)<br /><br /><br /><br /><br /></pre>TeX HeXhttp://www.blogger.com/profile/14268105680697143201noreply@blogger.comtag:blogger.com,1999:blog-7725030.post-55446511164238754282008-01-21T05:55:00.000-08:002008-01-21T06:06:27.691-08:00New Snom Auto update scriptSince Snom does now offer the v7 firmware officially, it was time to update my Snom update script. That's because the transition to v7 must be done if a very special way (first firmware 6.5.15, then linux 3.38 and then the special update firmware).<br /><br />Before you can use this script, you need to create several folders to include the parts you need to do the update:<br /><ul><li>/v6: includes the 6.5.15 firmware which is needed to update to v7 (snom3X0-6.5.15-SIP-j.bin)</li><li>/v6ux: includes the 3.38 Linux system also needed for v7 but can only be installed once the firmware is 6.5.15 (snom3X0-3.38-l.bin)</li><li>v6to7: this folder includes the special firmware that will update v6 to v7 while keeping all settings (snom3X0-update6to7-7.1.30-bf.bin)</li><li>v7: the normal firmware files for phones that already have v7 installed<br /></li></ul>All these files can be downloaded from <a href="http://wiki.snom.com/Firmware/V7/Update_Description">http://wiki.snom.com/Firmware/V7/Update_Description.</a><br /><br />To test it, you can simply use an URL like <span style="font-style: italic;">.../snom-firmware.asp?UA=Mozilla/4.0+(compatible;+snom320-SIP+6.5.15;+snom320+jffs2+v3.36;+snom320+linux+3.38) </span>which will tell the script you would like to use the User agent of a Snom 320.<br /><br />Once all these files are in place, you might use the following ASP script:<br /><br /><span style="font-family:courier new;"></span><br /><span style="font-family:courier new;"><pre><br /><br /><span style="font-family:courier new;"># Auto Update Skript</span><br /><span style="font-family:courier new;"># Coypright (C) 2007-2008 TeX HeX</span><br /><span style="font-family:courier new;"># http://texhex.blogspot.com</span><br /><span style="font-family:courier new;"># All Rights Reserved</span><br /><br /><span style="font-family:courier new;"><%</span><br /><span style="font-family:courier new;"> 'Example URLs (for testing):</span><br /><span style="font-family:courier new;"> '.../snom-firmware.asp?UA=Mozilla/4.0+(compatible;+snom320-SIP+6.5.10;+snom320+jffs2+v3.36;+snom320+linux+3.25)</span><br /><span style="font-family:courier new;"> '.../snom-firmware.asp?UA=Mozilla/4.0+(compatible;+snom320-SIP+6.5.15;+snom320+jffs2+v3.36;+snom320+linux+3.38)</span><br /><span style="font-family:courier new;"> '../snom-firmware.asp?UA=Mozilla/4.0+(compatible;+snom320-SIP+7.1.30)</span><br /><span style="font-family:courier new;"> 'Definition of download URLs</span><br /><span style="font-family:courier new;"> URL_BASE="http://my-server.internal.company.com/snom"</span><br /><span style="font-family:courier new;"> </span><br /><span style="font-family:courier new;"> URL_BASE_V6=URL_BASE & "/v6"</span><br /><span style="font-family:courier new;"> URL_BASE_V6_UX=URL_BASE & "/v6ux"</span><br /><span style="font-family:courier new;"> URL_BASE_V6TO7=URL_BASE & "/v6to7"</span><br /><span style="font-family:courier new;"> URL_BASE_V7=URL_BASE & "/v7"</span><br /><span style="font-family:courier new;"> </span><br /><span style="font-family:courier new;"> URL_V6_FW_300=URL_BASE_V6 & "/snom300-6.5.15-SIP-j.bin"</span><br /><span style="font-family:courier new;"> URL_V6_FW_320=URL_BASE_V6 & "/snom320-6.5.15-SIP-j.bin"</span><br /><span style="font-family:courier new;"> URL_V6_FW_360=URL_BASE_V6 & "/snom360-6.5.15-SIP-j.bin"</span><br /><span style="font-family:courier new;"> </span><br /><span style="font-family:courier new;"> URL_V6_UX_300=URL_BASE_V6_UX & "/snom300-3.38-l.bin"</span><br /><span style="font-family:courier new;"> URL_V6_UX_320=URL_BASE_V6_UX & "/snom320-3.38-l.bin"</span><br /><span style="font-family:courier new;"> URL_V6_UX_360=URL_BASE_V6_UX & "/snom360-3.38-l.bin"</span><br /><span style="font-family:courier new;"> </span><br /><span style="font-family:courier new;"> URL_V6TO7_FW_300=URL_BASE_V6TO7 & "/snom300-from6to7-7.1.30-bf.bin"</span><br /><span style="font-family:courier new;"> URL_V6TO7_FW_320=URL_BASE_V6TO7 & "/snom320-from6to7-7.1.30-bf.bin"</span><br /><span style="font-family:courier new;"> URL_V6TO7_FW_360=URL_BASE_V6TO7 & "/snom360-from6to7-7.1.30-bf.bin"</span><br /><span style="font-family:courier new;"> </span><br /><span style="font-family:courier new;"> URL_V7_FW_300=URL_BASE_V7 & "/snom300-7.1.30-SIP-f.bin"</span><br /><span style="font-family:courier new;"> URL_V7_FW_320=URL_BASE_V7 & "/snom320-7.1.30-SIP-f.bin"</span><br /><span style="font-family:courier new;"> URL_V7_FW_360=URL_BASE_V7 & "/snom360-7.1.30-SIP-f.bin"</span><br /><span style="font-family:courier new;"> '''URL_V7_FW_370=URL_BASE_V7 & "/snom370-7.1.30-SIP-f.bin"</span><br /><br /><span style="font-family:courier new;"> '----------STOP EDITING-------------------</span><br /><span style="font-family:courier new;"> Dim CRLF</span><br /><span style="font-family:courier new;"> CRLF=chr(13) + chr(10)</span><br /><br /><span style="font-family:courier new;"> Function Log(Text)</span><br /><span style="font-family:courier new;"> Response.Write("# " & Text)</span><br /><span style="font-family:courier new;"> Response.Write(CRLF)</span><br /><span style="font-family:courier new;"> End function</span><br /><span style="font-family:courier new;"> </span><br /><span style="font-family:courier new;"> Function SendOutFirmware_V6</span><br /><span style="font-family:courier new;"> Log("Sending v6 Firmware")</span><br /><span style="font-family:courier new;"> Call SendOutFirmware(URL_V6_FW_300,URL_V6_FW_320,URL_V6_FW_360)</span><br /><span style="font-family:courier new;"> End Function</span><br /><span style="font-family:courier new;"> </span><br /><span style="font-family:courier new;"> Function SendOutLinux_V6</span><br /><span style="font-family:courier new;"> Log("Sending v6 Linux")</span><br /><span style="font-family:courier new;"> Call SendOutFirmware(URL_V6_UX_300,URL_V6_UX_320,URL_V6_UX_360)</span><br /><span style="font-family:courier new;"> End Function</span><br /><span style="font-family:courier new;"> </span><br /><span style="font-family:courier new;"> Function SendOutFirmware_V6to7</span><br /><span style="font-family:courier new;"> Log("Sending v6 to v7 Firmware")</span><br /><span style="font-family:courier new;"> Call SendOutFirmware(URL_V6TO7_FW_300,URL_V6TO7_FW_320,URL_V6TO7_FW_360) </span><br /><span style="font-family:courier new;"> End Function</span><br /><span style="font-family:courier new;"> </span><br /><span style="font-family:courier new;"> Function SendOutFirmware_V7</span><br /><span style="font-family:courier new;"> Log("Sending v7 Firmware")</span><br /><span style="font-family:courier new;"> Call SendOutFirmware(URL_V7_FW_300,URL_V7_FW_320,URL_V7_FW_360)</span><br /><span style="font-family:courier new;"> End Function</span><br /><span style="font-family:courier new;"> </span><br /><span style="font-family:courier new;"> </span><br /><span style="font-family:courier new;"> Function SendOutFirmware(url300, url320, url360)</span><br /><span style="font-family:courier new;"> 'Only write out "firmware:"" tag if it's in the night (21:00 = 9 PM, 05:00 = 5 AM) </span><br /><span style="font-family:courier new;"> if ( (hour(now())>=21 or hour(now())<=5) or sNow="1" ) then</span><br /><span style="font-family:courier new;"> 'if true then </span><br /><span style="font-family:courier new;"> Dim sURL</span><br /><span style="font-family:courier new;"> </span><br /><span style="font-family:courier new;"> pos=InStr(sUA,"snom300")</span><br /><span style="font-family:courier new;"> if pos>0 then</span><br /><span style="font-family:courier new;"> sURL=url300</span><br /><span style="font-family:courier new;"> end if</span><br /><span style="font-family:courier new;"> </span><br /><span style="font-family:courier new;"> pos=InStr(sUA,"snom320")</span><br /><span style="font-family:courier new;"> if pos>0 then</span><br /><span style="font-family:courier new;"> sURL=url320</span><br /><span style="font-family:courier new;"> end if</span><br /><span style="font-family:courier new;"> </span><br /><span style="font-family:courier new;"> pos=InStr(sUA,"snom360")</span><br /><span style="font-family:courier new;"> if pos>0 then</span><br /><span style="font-family:courier new;"> sURL=url360</span><br /><span style="font-family:courier new;"> end if</span><br /><span style="font-family:courier new;"> </span><br /><span style="font-family:courier new;"> if len(sURL)>0 then</span><br /><span style="font-family:courier new;"> Response.Write("firmware: " + sURL)</span><br /><span style="font-family:courier new;"> Response.Write(CRLF)</span><br /><span style="font-family:courier new;"> else</span><br /><span style="font-family:courier new;"> Log("Unable to get download URL!")</span><br /><span style="font-family:courier new;"> end if </span><br /><span style="font-family:courier new;"> else</span><br /><span style="font-family:courier new;"> 'Debug output, I don't think Snoms can actually undestand this :)</span><br /><span style="font-family:courier new;"> Log("Firmware download disabled: It's not in the night! We have now: " + cstr(now()) )</span><br /><span style="font-family:courier new;"> end if </span><br /><span style="font-family:courier new;"> End Function</span><br /><span style="font-family:courier new;"> </span><br /><span style="font-family:courier new;"> </span><br /><span style="font-family:courier new;"> Dim sUA</span><br /><span style="font-family:courier new;"> sUA=Request.QueryString("UA")</span><br /><span style="font-family:courier new;"> if len(sUA)=0 then</span><br /><span style="font-family:courier new;"> Log("Parameter UA is empty, defaulting to HTTP_USER_AGENT")</span><br /><span style="font-family:courier new;"> sUA=Request.ServerVariables("HTTP_USER_AGENT")</span><br /><span style="font-family:courier new;"> Response.Write(CRLF)</span><br /><span style="font-family:courier new;"> end if</span><br /><span style="font-family:courier new;"> </span><br /><span style="font-family:courier new;"> Dim sNow</span><br /><span style="font-family:courier new;"> sNow=Request.QueryString("Now")</span><br /><span style="font-family:courier new;"> </span><br /><span style="font-family:courier new;"> 'Debug output, just for reference</span><br /><span style="font-family:courier new;"> Log("Parameter [USER AGENT] is --> " + sUA)</span><br /><br /><span style="font-family:courier new;"> Log("Parameter [Now] (direct update) is --> " + sNow)</span><br /><span style="font-family:courier new;"> </span><br /><span style="font-family:courier new;"> </span><br /><span style="font-family:courier new;"> 'Try to find out the current firmware version </span><br /><span style="font-family:courier new;"> Dim iPosStart,iPosEnd,sTmp</span><br /><span style="font-family:courier new;"> iPosStart=0</span><br /><span style="font-family:courier new;"> iPosEnd=0</span><br /><span style="font-family:courier new;"> sTmp=""</span><br /><span style="font-family:courier new;"> </span><br /><span style="font-family:courier new;"> 'Start searching</span><br /><span style="font-family:courier new;"> Log("Searching firmware version")</span><br /><span style="font-family:courier new;"> iPosStart=InStr(sUA,"-SIP")</span><br /><span style="font-family:courier new;"> if iPosStart>0 then </span><br /><span style="font-family:courier new;"> sTmp=Right(sUA,len(sUA)- (iPosStart+4)) '+4 to cut the "SIP " part</span><br /><span style="font-family:courier new;"> Call Log("Version sniffing - part 1: " + sTmp)</span><br /><span style="font-family:courier new;"> </span><br /><span style="font-family:courier new;"> 'now search for next ;</span><br /><span style="font-family:courier new;"> iPosEnd=InStr(sTmp,";")</span><br /><span style="font-family:courier new;"> if iPosEnd>0 then</span><br /><span style="font-family:courier new;"> sTmp=left(sTmp,iPosEnd-1)</span><br /><span style="font-family:courier new;"> Call Log("Version: " + sTmp)</span><br /><span style="font-family:courier new;"> else</span><br /><span style="font-family:courier new;"> 'maybe a new 7.x phone - search for ")"</span><br /><span style="font-family:courier new;"> iPosEnd=InStr(sTmp,")")</span><br /><span style="font-family:courier new;"> if iPosEnd>0 then</span><br /><span style="font-family:courier new;"> sTmp=left(sTmp,iPosEnd-1)</span><br /><span style="font-family:courier new;"> Call Log("Version: " + sTmp)</span><br /><span style="font-family:courier new;"> end if</span><br /><span style="font-family:courier new;"> end if </span><br /><span style="font-family:courier new;"> end if</span><br /><span style="font-family:courier new;"> </span><br /><span style="font-family:courier new;"> 'Log sTmp</span><br /><span style="font-family:courier new;"> </span><br /><span style="font-family:courier new;"> Dim sCurVersion</span><br /><span style="font-family:courier new;"> sCurVersion=""</span><br /><span style="font-family:courier new;"> </span><br /><span style="font-family:courier new;"> 'Now check if the version can be found!</span><br /><span style="font-family:courier new;"> if iPosStart<=0 or iPosEnd<=0 then</span><br /><span style="font-family:courier new;"> 'No version info found, send to last v6 release!</span><br /><span style="font-family:courier new;"> Call Log("No version info found!")</span><br /><span style="font-family:courier new;"> Call SendOutFirmware_V6() </span><br /><span style="font-family:courier new;"> else</span><br /><span style="font-family:courier new;"> 'Okay, we have a version! If this is 6.5.15 we need to send out the newest linux!</span><br /><span style="font-family:courier new;"> sCurVersion=sTmp</span><br /><span style="font-family:courier new;"> Call Log("Found version: " & sCurVersion)</span><br /><span style="font-family:courier new;"> </span><br /><span style="font-family:courier new;"> if CInt(left(sCurVersion,1))<=6 and sCurVersion<>"6.5.15" then</span><br /><span style="font-family:courier new;"> Call Log("Version is 6 or below but not 6.5.15!")</span><br /><span style="font-family:courier new;"> Call SendOutFirmware_V6()</span><br /><span style="font-family:courier new;"> else</span><br /><span style="font-family:courier new;"> 'Is this 6.5.15?</span><br /><span style="font-family:courier new;"> If sCurVersion="6.5.15" then</span><br /><span style="font-family:courier new;"> 'Do we need to do a linux update?</span><br /><span style="font-family:courier new;"> iPosStart=0</span><br /><span style="font-family:courier new;"> iPosEnd=0</span><br /><span style="font-family:courier new;"> sTmp=""</span><br /><span style="font-family:courier new;"> </span><br /><span style="font-family:courier new;"> Log("Searching linux version")</span><br /><span style="font-family:courier new;"> iPosStart=InStr(sUA," linux")</span><br /><span style="font-family:courier new;"> if iPosStart>0 then </span><br /><span style="font-family:courier new;"> sTmp=Right(sUA,len(sUA)- (iPosStart+6)) '+4 to cut the " linux" part</span><br /><span style="font-family:courier new;"> Call Log("Version sniffing - part 1: " + sTmp)</span><br /><span style="font-family:courier new;"> </span><br /><span style="font-family:courier new;"> 'now search for )</span><br /><span style="font-family:courier new;"> iPosEnd=InStr(sTmp,")")</span><br /><span style="font-family:courier new;"> if iPosEnd>0 then</span><br /><span style="font-family:courier new;"> sTmp=left(sTmp,iPosEnd-1)</span><br /><span style="font-family:courier new;"> Call Log("Version: " + sTmp)</span><br /><span style="font-family:courier new;"> end if </span><br /><span style="font-family:courier new;"> end if</span><br /><span style="font-family:courier new;"> </span><br /><span style="font-family:courier new;"> if iPosStart<=0 or iPosEnd<=0 then</span><br /><span style="font-family:courier new;"> Log("Unable to find linux version!")</span><br /><span style="font-family:courier new;"> else</span><br /><span style="font-family:courier new;"> if sTmp<>"3.38" then</span><br /><span style="font-family:courier new;"> Log("Version to old, sending new linux!")</span><br /><span style="font-family:courier new;"> Call SendOutLinux_V6()</span><br /><span style="font-family:courier new;"> else </span><br /><span style="font-family:courier new;"> 'Firmware is 6.5.15 and linux version okay!</span><br /><span style="font-family:courier new;"> '-> Update to 7.1.30!</span><br /><span style="font-family:courier new;"> Call SendOutFirmware_V6to7()</span><br /><span style="font-family:courier new;"> end if </span><br /><span style="font-family:courier new;"> end if </span><br /><span style="font-family:courier new;"> else </span><br /><span style="font-family:courier new;"> 'Firmware is not 6.5.15/UX 3.38, more like 7+</span><br /><span style="font-family:courier new;"> Call SendOutFirmware_V7()</span><br /><span style="font-family:courier new;"> end if </span><br /><span style="font-family:courier new;"> end if </span><br /><span style="font-family:courier new;"> end if </span><br /><span style="font-family:courier new;"> </span><br /><br /><br /><span style="font-family:courier new;"> Log("Done!")</span><br /><br /><span style="font-family:courier new;">%></span><br /><br /><span style="font-family:courier new;"></span></pre></span><br /><span style="font-family:courier new;"></span><br /><br /></pre><br /></pre>TeX HeXhttp://www.blogger.com/profile/14268105680697143201noreply@blogger.comtag:blogger.com,1999:blog-7725030.post-11558120085397874612008-01-14T23:30:00.000-08:002008-01-14T23:34:32.532-08:00SOME of your network connections are down<span style="font-weight: bold;">SOME</span> of your network connections are down...<br /><br /><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/_V1tbWNn9eRE/R4xhXsCRTaI/AAAAAAAAAHE/qCu4kU5H6w8/s1600-h/network-down.PNG"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer; width: 506px; height: 25px;" src="http://bp1.blogger.com/_V1tbWNn9eRE/R4xhXsCRTaI/AAAAAAAAAHE/qCu4kU5H6w8/s400/network-down.PNG" alt="" id="BLOGGER_PHOTO_ID_5155602733017943458" border="0" /></a>TeX HeXhttp://www.blogger.com/profile/14268105680697143201noreply@blogger.comtag:blogger.com,1999:blog-7725030.post-1070763100704059062008-01-09T03:38:00.001-08:002008-01-09T03:39:35.804-08:00Lost in translation: ASC16-UTF8-1252<p class="MsoNormal"><span lang="EN-US" style="font-family:Verdana;">As soon as you start to deal with any string data, you need to make sure of which character encoding type this string is. The most commonly used are ASCII, ISO-8859-1, Windows-1252 and the two Unicode encodings UTF-8 and UTF-16.<o:p></o:p></span></p> <p class="MsoNormal"><span lang="EN-US" style="font-family:Verdana;"><o:p></o:p>Normally, you can fully ignore which character encoding you are using but as soon as you need to communicate with an external source, or need to make sure in which format an external data source is, you need to know the encoding. <o:p></o:p></span></p> <p class="MsoNormal"><span lang="EN-US" style="font-family:Verdana;">Here is the list of the most commonly used encodings:</span></p> <p class="MsoNormal"><span lang="EN-US" style="font-family:Verdana;"><span style="font-weight: bold;">ASCII</span> (<a href="http://www.asciitable.com/">http://www.asciitable.com/</a>) is very old but still very widely used. Every character consists of one byte but only the values 0 – 127 are defined which makes it 7 bit. The characters between 128 and 255 (8 bit) are so called "Extended ASCII" and which characters they map can be defined in a codepage. This means: If you are using data that contains ASCII characters about 127, you need to make sure that sender and receiver use the same codepage.<o:p></o:p></span></p> <p class="MsoNormal"><span lang="EN-US" style="font-family:Verdana;"><span style="font-weight: bold;">ISO-8859-1 Latin-1</span> (<a href="http://en.wikipedia.org/wiki/ISO/IEC_8859-1">http://en.wikipedia.org/wiki/ISO/IEC_8859-1</a>) is very widely used in the internet since it's the default encoding for the "text/" MIME type. Basically it's a codepage that maps 0 – 127 to the same characters like ASCII, 128 and above to several characters of the Latin alphabet. <o:p></o:p></span></p> <p class="MsoNormal"><span lang="EN-US" style="font-family:Verdana;"><o:p> </o:p></span></p> <p class="MsoNormal"><span lang="EN-US" style="font-family:Verdana;"><span style="font-weight: bold;">Windows-1252</span> (<a href="http://en.wikipedia.org/wiki/Windows-1252">http://en.wikipedia.org/wiki/Windows-1252</a>) is based on ISO-8859-1 and is still the most used codepage for Windows. It differs in the 0x80 to 0x9F range which contains non-printable characters in ISO-8859-1 but printable characters on Windows-1252.<o:p></o:p></span></p> <p class="MsoNormal"><span lang="EN-US" style="font-family:Verdana;"><o:p> </o:p></span></p> <p class="MsoNormal"><span lang="EN-US" style="font-family:Verdana;"><span style="font-weight: bold;">UTF-8</span> (<a href="http://en.wikipedia.org/wiki/Utf-8">http://en.wikipedia.org/wiki/Utf-8</a>) is a Unicode character encoding that again maps 0 – 127 like ASCII but can also display all Unicode characters. UTF-8 is a variable-length encoding which means the values 0-255 is mapped to one byte, like in "Extended ASCII", but UTF-8 can use two, three or even four bytes per character when needed. Because of this variable-length encoding and the backward compatibility with ASCII, it is the encoding you should use. <o:p></o:p></span></p> <p class="MsoNormal"><span lang="EN-US" style="font-family:Verdana;"><o:p> </o:p></span></p> <p class="MsoNormal"><span lang="EN-US" style="font-family:Verdana;"><span style="font-weight: bold;">UTF-16</span> (<a href="http://en.wikipedia.org/wiki/UTF-16">http://en.wikipedia.org/wiki/UTF-16</a>) is also a Unicode character encoding but maps 0 – 127 differently from ASCII and uses only two or four bytes per character. Because of this it requires more data space and should only be used if you need to use. Use UTF-8 in any other case.<o:p></o:p></span></p>TeX HeXhttp://www.blogger.com/profile/14268105680697143201noreply@blogger.comtag:blogger.com,1999:blog-7725030.post-91008335484510936542007-12-31T07:59:00.000-08:002007-12-31T08:00:16.273-08:00Strange Delphi Bug – again<o:p style="font-family: verdana;"></o:p><span style="font-family: verdana;" lang="EN-US">It really seems that somebody at Borland/CodeGear hates me. Why? Because with every new release of Delphi I run into a very strange bug. This time: The type library editor on Vista “<i style="">can’t rename XXX.$$$ to XXX.tlb</i>”.<o:p></o:p></span> <p style="font-family: verdana;" class="MsoNormal">The first message of this bug will be “<i style="">Can’t copy XXX.tlb to __history\XXX.~1~</i>” (or something like that). Okay, no problem simply switching off backup copies (Preferences – Editor) and you are done. Not really, since now Delphi will throw a new error “<i style="">Can’t rename XXX.$$$ to XXX.tlb</i>”. Checking with Process Monitor reveals that Delphi itself (BDS.exe) is locking the TLB file. Nice, isn’t it? <o:p></o:p></p> <p style="font-family: verdana;" class="MsoNormal">Looking a little bit around and it seems this bug only appear when Delphi is installed on Vista AND the type library you are editing has a reference to OLE Automation v1.0 (stdole32.tlb). If the type library has a reference to OLE Automation v2.0 (stdole2.tlb) this bug won’t show up. The solution I found was to open the project on Windows XP, exchange the reference and reopen the project on Vista. But I don’t have an XP box anymore so the solution was a little bit strange:<o:p></o:p></p> <p style="font-family: verdana;" class="MsoNormal">Exchange the reference of OLE Automation v1.0 to v2.0 inside the Type Library Editor (Tab “Uses”), then try to compile the project. This will fail because of the “Can’t rename…” error. Anyway, copy the <i style="">[FILENAME].$$$</i> from the project folder to a new folder while Delphi is running. Once this is done, close BDS (no, you can’t save the project because of the error). Now delete the old TLB file and rename <i style="">[FILENAME].$$$</i> to <i style="">[FILENAME].TLB</i> and copy it to the project folder. <o:p></o:p></p> <p style="font-family: verdana;" class="MsoNormal">Start Delphi again, open the project and check if the “Uses” tab now says you are using OLE Automation Version 2.0. If so, everything should be back to normal again.<o:p></o:p></p>TeX HeXhttp://www.blogger.com/profile/14268105680697143201noreply@blogger.comtag:blogger.com,1999:blog-7725030.post-73558273015373821492007-12-27T03:24:00.000-08:002008-01-28T03:25:57.751-08:00I just want a !"§$% iPod bag!<p class="MsoNormal"><span style="" lang="EN-US">Okay, I finally managed it to buy me a new iPod Classic 80GB since my 2<sup>nd</sup> generation iPod seems to have some gremlins.<o:p></o:p></span></p> <p class="MsoNormal"><span style="" lang="EN-US">As I know that Apple does no longer deliver a bag, I through it should be easy to get a bag from a 3<sup>rd</sup> party. Boy was I wrong.<o:p></o:p></span></p> <p class="MsoNormal"><span style="" lang="EN-US">You basically get everything, silicon slip-in cases, sports armband cases, charge cases, kitty cat cases.... But I just wanted a simple case. Means: Put the iPod in for transportation and put it out if you plan to use it or not.<o:p></o:p></span></p> <p class="MsoNormal"><span style="" lang="EN-US">Believe me or not, the <span style="font-weight: bold;">only</span> simple case I found was one from Marware: <a href="http://www.marware.com/PRODUCTS/Cases-for-iPod-Classic/Sportsuit-Sleeve-for-iPod-classic">Sportsuit Sleeve for iPod classic and video</a>.<o:p></o:p></span></p> <p class="MsoNormal"><span style="" lang="EN-US">Sometimes the simple things are just so hard to get. <o:p></o:p></span></p>TeX HeXhttp://www.blogger.com/profile/14268105680697143201noreply@blogger.comtag:blogger.com,1999:blog-7725030.post-62911946296532445622007-12-11T02:58:00.001-08:002007-12-11T02:59:45.806-08:00Hostile AdOkay, I don't like Macs, I don't have one and I think Vista is better than MacOS X.<br /><br />But this add is just so funny...<br /><br /><br /><a style="left: 0px ! important; top: 0px ! important;" title="Click here to block this object with Adblock Plus" class="abp-objtab-014720913353859288 visible ontop" href="http://www.youtube.com/v/ZRAUlK8_2VE&rel=1"></a><object height="355" width="425"><param name="movie" value="http://www.youtube.com/v/ZRAUlK8_2VE&rel=1"><param name="wmode" value="transparent"><embed src="http://www.youtube.com/v/ZRAUlK8_2VE&rel=1" type="application/x-shockwave-flash" wmode="transparent" height="355" width="425"></embed></object>TeX HeXhttp://www.blogger.com/profile/14268105680697143201noreply@blogger.comtag:blogger.com,1999:blog-7725030.post-8398354489212370072007-11-14T12:28:00.001-08:002007-11-15T03:38:38.558-08:00Windows Vista's Constant HD Activity Craziness<span xmlns="" style="font-size:100%;"><p><span style="font-family:Verdana;">Any user that has used Windows XP and updating to Vista will notice one thing: In Vista, your hard drive thinks it's a bewitched lawnmower – it's always active. Even after all startup programs are loaded, the HD is still active: Vista's</span><span style="font-family:Verdana;"> Constant HD Activity Craziness.</span></p><p><span style="font-family:Verdana;">Beside the typical babble of "Microsoft is now reading all your files and sent them to Redmond to gain the world domination!" the funny thing is that I was not able to find a resource on the web that describes what Vista is doing all the time. Therefore I decided to write this little article and listing all processes that cause a lot of HD activity, what they are doing and how they can be configured.</span></p><p><span style="font-family:Verdana;"><strong>Introduction<br /></strong></span></p><p><span style="font-family:Verdana;">Especially the typical XP user switching to Vista will notice that the HD is much more used in Vista than it was in XP. But why are these users (like me) noticing this anyway? Because in XP HD activity usually meant: "I'm busy. Go away.". In Vista this is not necessarily true. Even if HD led is gleaming all the time, you can mostly use Vista as if there would be no HD activity – thanks to several changes Microsoft has done in Vista.<br /></span></p><p><span style="font-family:Verdana;">For example, several programs and services will now use an IO (Input/output) Priority of "Background". This simply means, if there is no work to do for the HD,</span><span style="font-family:Verdana;"> these programs will get the full speed of it (e.g. 15 MB/sec). As soon as a program with "Normal" priority is started, e.g. you double-click the iTunes icon, this program is getting full access (15 MB/sec) and the "Background" program is delayed (0 MB/sec). This will start iTunes as fast as you would expect it although there is another program in the background that is using the HD heavily.<br /></span></p><p><span style="font-family:Verdana;">So, the first thing to notice is that a constantly flushing HD LED is not such a performance killer as it was in XP. Secondly, all these services I'm listing are</span><span style="font-family:Verdana;"> basically good configured out of the box and worth the stress they put on your HD. Except for some configurations, you do not need to disable any reconfigure any of them.<br /></span></p><p><span style="font-family:Verdana;">Below I have noted the features of Windows that know I know so far that cause a lot of HD activity. For eac</span><span style="font-family:Verdana;">h feature, I also noted the process name that appear</span><span style="font-family:Verdana;">s in "Resource Monitor" so you know what is currently executing. For a description how to start Resource Monitor, please look at the bottom of this article.<br /></span></p><p><span style="font-family:Verdana;"><strong><br /></strong></span></p><p><span style="font-family:Verdana;"><strong>SuperFetch<br /></strong></span></p><p><span style="font-family:Verdana;"><strong>Displayed in Resource Monitor as: svchost.exe</strong></span><span style="font-family:Verdana;"><strong> (LocalSystemNetworkRestricted)</strong></span></p><p><span style="font-family:Verdana;">To understand what SuperFetch does, you first need to understand what is happening when you load a file (regardless if it's a program or a document like a PDF).</span></p><p><span style="font-family:Verdana;">Any file you are dealing with needs to be put into memory before your CPU can use it. This means that the different chunks of the file need to be retrieved from your HD and loaded into memory.</span></p><p><span style="font-family:Verdana;">Think of a file as a song on a platter and the HD is the record player for this platter. To retrieve the file, the pickup of the record player needs to be moved forwarded until the song (file) begins and then read it until it's over.<br /></span></p><p><span style="font-family:Verdana;">In an ideal world, all files are organized as the songs on a platter: Song 1, Song 2, Song 3. However, in real life it's more like Song 1 Part A, Song 2 Part B, Song 1 Part C, Song 2 Part A, Song 1 Part B etc. You see, the pickup needs to move a lot until it has collected the complete Song 1. This moving around the entire</span><span style="font-family:Verdana;"> platter simply takes time.<br /></span></p><p><span style="font-family:Verdana;">If an HD can read a file in one "move" this is called sequential I/O (Input/Output) and it's very fast – you can expect 50 MB per second or more. However, if the HD needs several "moves" until it has found the entire song (Random I/O), it will drop to 3 MB per Second or even less.</span></p><p><span style="font-family:Verdana;">And this is one of the scenarios where SuperFetch kicks in: SuperFetch will first try to optimize this</span><span style="font-family:Verdana;"> </span><span style="font-family:Verdana;">moving so files (songs) can be retrieved faster. Given the example from above (Song 1 Part A, Song 2 Part B, Song 1 Part C, Song 2 Part A, Song 1 Part B) a "stupid" load</span><span style="font-family:Verdana;"> would first retrieve Song 1 Part A, then Song 1 Part B, then Song 1 Part C.</span></p><p><span style="font-family:Verdana;">SuperFetch would in this case retrieve Song 1 Part A, then Song 1 Part C, then Song 1 Part B (as C comes before B on the platter) and later on reorder them in memory. With this optimization the data is more sequential retrieved and thus faster. Of course, in this simple example you would not notice any performance gain but think of a song with 50, 200 or even 500 fragments.</span></p><p><span style="font-family:Verdana;">The second optimizations sounds a little bit like Voodoo: SuperFetch will tr</span><span style="font-family:Verdana;">y to read data from the HD BEFORE it's actually needed.<br /></span></p><p><span style="font-family:Verdana;">A good example of this is that you launch, each time you start Windows, Firefox and Outlook. Because SuperFetch will learn this the start of either Firefox or Outlook is very fast simply because there is no HD activity anymore: the data is in the memory already.</span></p><p><span style="font-family:Verdana;">Or, you might start a game during lunch. As you do it regularly, SuperFetch can learn over time that the data of this game is needed every day at 12:04 (four minutes until your boss has left the office:-). SuperFetch will in</span><span style="font-family:Verdana;"> this case pre-load the data from the HD to the memory so when you start the program, Vista does not read it from the HD but has the data ready-to-use in memory.</span></p><p><span style="font-family:Verdana;">You can also monitor this in task manager: Directly after you have started Windows, you have plenty of free memory and only some data inside the cache.</span><span><span xmlns="" style="font-size:100%;"><span><span xmlns="" style="font-size:100%;"><span><span xmlns="" style="font-size:100%;"><span><span xmlns="" style="font-size:100%;"><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp3.blogger.com/_V1tbWNn9eRE/Rztdumn8NWI/AAAAAAAAAEQ/Eeyo9XiHjMY/s1600-h/pic9_taskman1.jpg"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp3.blogger.com/_V1tbWNn9eRE/Rztdumn8NWI/AAAAAAAAAEQ/Eeyo9XiHjMY/s320/pic9_taskman1.jpg" alt="" id="BLOGGER_PHOTO_ID_5132799255542248802" border="0" /></a></span></span></span></span></span></span></span></span></p><p><span style="font-family:Verdana;">If you wait 1-4 minutes, the cache will be filled:</span></p><p><span><span xmlns="" style="font-size:100%;"><span><span xmlns="" style="font-size:100%;"><span><span xmlns="" style="font-size:100%;"><span><span xmlns="" style="font-size:100%;"><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp0.blogger.com/_V1tbWNn9eRE/Rztdu2n8NXI/AAAAAAAAAEY/aurBkuSRr0U/s1600-h/pic10_taskman2.jpg"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp0.blogger.com/_V1tbWNn9eRE/Rztdu2n8NXI/AAAAAAAAAEY/aurBkuSRr0U/s320/pic10_taskman2.jpg" alt="" id="BLOGGER_PHOTO_ID_5132799259837216114" border="0" /></a></span></span></span></span></span></span></span></span></p><p><span style="font-family:Verdana;">And before you ask: No, this memory is not gone and you do not need any stupid memory manager. If you start an application that requires memory, the cache will be cleared (in less than a second) and ready to be used by any application that</span><span style="font-family:Verdana;"> requires it.<br /></span></p><p><span style="font-family:Verdana;">SuperFetch has some more strategies and if you are interested, watch this video:<br /></span></p><p><a href="http://channel9.msdn.com/showpost.aspx?postid=242429"><span style="font-family:Verdana;">http://channel9.msdn.com/showpost.aspx?postid=242429</span></a><span style="font-family:Verdana;"> </span></p><p><span style="font-family:Verdana;">If you wish to stop SuperFetch from doing this, simply disable the service "SuperFetch" (see the bottom of this article how to disable a service).<br /></span></p><p><span style="font-family:Verdana;"><strong><br /></strong></span></p><p><span style="font-family:Verdana;"><strong>System Protection</strong></span></p><p><span style="font-family:Verdana;"><strong>Displayed in Resource Monitor as: System (with PID 4) accessing C:\System Volume Information</strong></span></p><p><span style="font-family:Verdana;">System Restore is a combination of two completely different techniques: Restore Points and Previous Version. By default, it runs on every system startup once a day and then on midnight.</span></p><p><span style="font-family:Verdana;">Restore Points might be known from Windows XP already and helps to recover if Windows won't boot any more. It simply takes a backup of important system files and configuration information (Registry) and stores them. If Windows is unable to boot, you can use the DVD and repair your Windows. For example, if you install a new driver (which will trigger the creation of a restore point automatically) and this driver is crashing upon start, Windows will simply restore the Restore Point and can be started again.<br /></span></p><p><span style="font-family:Verdana;">Beside this restore, you can also use System Protection to go back to a Restore Point in Windows itself. This is mostly used if you system is acting "strange", but still boots and you don't know what this has caused.<br /></span></p><p><span style="font-family:Verdana;">The creation of a Restore Point is very fast, for example on my system it only takes round about 20 seconds.</span></p><p><span style="font-family:Verdana;">After the creation of the Restore Point, previous versions will start which is a technique to create backup copies of your files. Every time it runs it will check if a given file has been changed since the last backup and if so, create a backup copy. You can access a previous version of a file by simply right-clicking it and opening the "Previous Versions" tab. If you have deleted a file, you can also right-click the folder where it was stored and select "Previous Versions". Windows will then display all previous versions it has saved from this folder and you can simply view the contents by clicking "Open".</span><span><span xmlns="" style="font-size:100%;"><span xmlns="" style="font-size:100%;"><p><a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://bp1.blogger.com/_V1tbWNn9eRE/RztdlGn8NVI/AAAAAAAAAEI/z3ZEkVijrAY/s1600-h/pic8_prev-vers-desktop.JPG"><img style="margin: 0px auto 10px; display: block; text-align: center; cursor: pointer;" src="http://bp1.blogger.com/_V1tbWNn9eRE/RztdlGn8NVI/AAAAAAAAAEI/z3ZEkVijrAY/s320/pic8_prev-vers-desktop.JPG" alt="" id="BLOGGER_PHOTO_ID_5132799092333491538" border="0" /></a></p></span></span></span></p><p><span style="font-family:Verdana;">The big difference between Previous Versions and a "normal" backup tool is that previous versions are using a technique called "Shadow Copies". When previous versions are instructed to start, it will first ask Windows to create a shadow copy of the entire drive. Windows will stop all write requests to the HD for some seconds and then create a virtual copy of your HD. The creation of the shadow copy only takes some seconds more and after that, previous versions will start to work with the shadow copy of your HD.<br /></span></p><p><span style="font-family:Verdana;">Although this sounds a little bit like magic creating a copy of a 100 GB HD in some seconds, you need to remember that this is only a virtual copy. This means, Windows will not create a 100 GB file called DISK.IMG. What shadow copy does is that it will, as soon as a file is changed, copy this file and include it in its virtual copy. If a file is not changed or deleted, shadow copy will simply use the file as it is on your HD. That's the reason why it will stop all requests for some seconds to copy the files that are currently accessed or changed. Explaining more detailed how shadow copies work would take too long, so if you interested see the technical documentation on <a href="http://msdn2.microsoft.com/en-us/library/aa384961.aspx">http://msdn2.microsoft.com/en-us/library/aa384961.aspx</a> or view the following video on Channel 9: <a href="http://channel9.msdn.com/Showpost.aspx?postid=286303">http://channel9.msdn.com/Showpost.aspx?postid=286303</a><br /></span></p><p><span style="font-family:Verdana;">With the virtual copy of your HD shadow copies has created, previous versions will simply check each and every file if it has changed since it was last backed up. If so, a backup copy is saved. This will also be true for directories but only changes will be saved. For example, if you have added a new file to the folder "Desktop", previous versions will not save the