By Ken Huysmans on
2007-04-09T18:44:03
Today I received a PC of a customer with a huge history of virus and spyware infections. It was impossible to connect the PC to a network.
I ran AVG Antivirus Free and AVG Antispyware Free to remove the remainders of the unwanted software, but still no network access. When I tried to ping my router I got some strange characters in the output window.
As usual, Google served the answer and pointed to Microsoft Knowledgebase Article 817571. Method 1 restored the network functionality.
|
By Ken Huysmans on
2006-10-11T16:58:31
I wanted to add a column to a list to store a date based on some heavy business-logic (the calculated column could not be used for this). The end user needs to be able to see the contents of this column, but should not be able to modify it.
Walking through the Sharepoint object model I discovered the CreateNewField Function on the SPFieldCollection in the desired list.
This (at the moment almost undocumented) function needs two parameters:
- typeName As String
- displayName As String
and is returning a SPField.
I had some trouble with the first parameter as it was not clear what exact it was expecting, most of the time the function just throwed a null reference exception (guessing because the errormessage still doesn't exist in the resource file). So I did some investigation with Reflector.
The typeName is expected to be one of the members of
Microsoft.SharePoint.SPFieldType enumeration ("DateTime" in my case).
Dim sps As New...
Read More »
|
By Ken Huysmans on
2006-04-07T11:32:07
iText# (iTextSharp) is a port of the iText open source java library written entirely in C# for the .NET platform. iText# is a library that allows you to generate PDF files on the fly. It is implemented as an assembly.
The code of the class I've written uses iText# and is based on the example code (Console Application) that can be found on http://itextsharp.sourceforge.net/examples/Concat.cs . However, this code seems to target an out of date version of iText# and can't be compiled without fixing some lines...
This C#-class will allow you to merge multiple PDF's to one big PDF-file:
// Based on : http://itextsharp.sourceforge.net/examples/Concat.cs
using System;
using System.IO;
using iTextSharp.text;
using iTextSharp.text.pdf;
public class PdfMerge
{
public static void MergeFiles(string destinationFile, string[] sourceFiles)
{
try
{
int f = 0;
//...
Read More »
|
By Ken Huysmans on
2006-03-08T11:16:56
You just have finished your application, the only thing you need is an icon. You don't have icons on your machine and you don't have the graphical skills to create one. But... you have an image on your PC or you found one on Google (watch out for copyrights!) that could be used, too bad it's not in .ico format.
But since you're a .NET-coder, you can create an application to convert an image to an icon in less then one minute!
Have a look at this demo application.
Create a new Windows Application
Set the value of the AllowDrop property of the form to True
Add this code to the DragEnter event of the form
Private Sub Form1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles MyBase.DragEnter
If e.Data.GetDataPresent(DataFormats.FileDrop) Then
e.Effect = DragDropEffects.Copy
Else
e.Effect = DragDropEffects.None
End If
End Sub
Add code to the DragDrop event of the form
Private Sub Form1_DragDrop(ByVal sender As Object,...
Read More »
|
By Ken Huysmans on
2006-03-08T08:27:25
Some months ago I published an article explaining how to copy a file with a progressbar in VB.NET. I would like to thank you all for the great feedback on that article! Some days ago I received a mail with the question how to copy a whole directorystructure while showing the progress. So here's a possible solution. Please have a look at the original article first (http://www.khswsoft.be/Blog/tabid/81/EntryID/12/Default.aspx).
The necessary API functions:
Private Delegate Function CopyProgressRoutine(ByVal totalFileSize As Int64, ByVal totalBytesTransferred As Int64, ByVal streamSize As Int64, ByVal streamBytesTransferred As Int64, ByVal dwStreamNumber As Int32, ByVal dwCallbackReason As Int32, ByVal hSourceFile As Int32, ByVal hDestinationFile As Int32, ByVal lpData As Int32) As Int32
Private Declare Auto Function CopyFileEx Lib "kernel32.dll" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal lpProgressRoutine As CopyProgressRoutine, ByVal lpData As Int32, ByVal lpBool As Int32, ByVal dwCopyFlags As Int32) As Int32...
Read More »
|
By Ken Huysmans on
2006-01-12T14:15:00
If you use the default TreeView in Visual Studio 2003, the SelectedNode property doesn't always return the correct selected node in the Click event.
If you inherit from the TreeView, you can override the OnMouseDown event with this code:
Protected Overrides Sub OnMouseDown(ByVal e As System.Windows.Forms.MouseEventArgs)
Me.SelectedNode = Me.GetNodeAt(New Point(e.X, e.Y))
MyBase.OnMouseDown(e)
End Sub
Otherwise, you can add this code to your form in the OnClick event of the Treeview:
Private Sub TreeView1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles TreeView1.MouseDown
TreeView1.SelectedNode = TreeView1.GetNodeAt(New Point(e.X, e.Y))
End Sub
|
By Ken Huysmans on
2005-08-03T10:49:02
Today I wanted to create a control that could copy files in VB.NET with some progress indication. I did some searches on the Internet and managed to build a working control. However, I would like to share the basics with all of you...
First declare some API functions:
Private Delegate Function CopyProgressRoutine(ByVal totalFileSize As Int64, ByVal totalBytesTransferred As Int64, ByVal streamSize As Int64, ByVal streamBytesTransferred As Int64, ByVal dwStreamNumber As Int32, ByVal dwCallbackReason As Int32, ByVal hSourceFile As Int32, ByVal hDestinationFile As Int32, ByVal lpData As Int32) As Int32
Private Declare Auto Function CopyFileEx Lib "kernel32.dll" (ByVal lpExistingFileName As String, ByVal lpNewFileName As String, ByVal lpProgressRoutine As CopyProgressRoutine, ByVal lpData As Int32, ByVal lpBool As Int32, ByVal dwCopyFlags As Int32) As Int32
Add a button (Button1) to your form and add this code to the Click event:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)...
Read More »
|
By Ken Huysmans on
2005-03-25T08:25:42
This looks like normal behaviour to me, but recently someone asked how to prevent this as he just called a Javascript function in a hyperlink. Something like this:
<a href="javascript:DoSomething()"><img src="animated.gif" border="0"></a>
He didn't want the animations to stop when clicking that link, so we rewrote this line to:
<a href="#" onclick="javascript:DoSomething();return false"><img src="animated.gif" border="0"></a>
|
By Ken Huysmans on
2005-02-18T11:27:59
One day you might encounter a user who has done some cleaning (thouroughly) on his PC. Your program crashes because it can't find some necessary files...
A reinstall will do the trick, but there's a more user-friendly way to cope with 'deleters'.
I'm going to use images in my example, but you could do this with every file you want (since you'll be getting a Stream).
Add an image to your project and make sure to put the Build Action to Embedded Resource.
Now here's some code to retrieve the image, the function GetEmbeddedImagePath() will return the filename, the function GetEmbeddedImage() will return an Image object. They both need 1 parameter, the name of the image you want to retrieve.
Public Shared Function GetEmbeddedImagePath(ByVal imageName As String) As String
Dim f, fn As String
f = Application.StartupPath
If Not f.EndsWith("\") Then f &= "\"
f &= "Images\"
fn = f & imageName
If File.Exists(fn) Then
Return fn
Else
If Not Directory.Exists(f) Then
Directory.CreateDirectory(f)
End If...
Read More »
|
By Ken Huysmans on
2004-11-28T13:51:37
This is a question I received a while ago. After an upgrade to Windows XP SP2 the 'My Documents' folder always opened when Windows was started.
I ran msconfig, but couldn't find anything suspicious... After a while I found out there was something wrong with the 'userinit'-key in the registry.
The value of this key (HKEY_LOCAL_MACHINE\Software\Microsoft\Windows NT\CurrentVersion\Winlogon\UserInit) was C:\WINDOWS\system32\userinit.exe,C:\WINDOWS\system32\userinit.exe.
Changing this key to only C:\WINDOWS\system32\userinit.exe solved the problem.
|