VB6 – Detecting whether the program is running under the control of Visual Studio or not..

Drag Article : Moved from Old Blog

Private Declare Function GetModuleHandle _
Lib "kernel32" Alias _
"GetModuleHandleA" _
(ByVal lpModuleName As String) As Long </span>
<span style="font-family: verdana; font-size: 85%">
Public Function TestEnvironment() As Boolean
Dim ModuleHandle As String
Dim EnvFileName As String
Dim EnvVal As Variant
Dim ReturnVal As Long
Dim i As Long
EnvVal = _
Array("vb.exe", _
"vb32.exe", _
"vb5.exe", _
"vb6.exe")
For i = LBound(EnvVal) To UBound(EnvVal)
ModuleHandle = EnvVal(i)
ReturnVal = GetModuleHandle(ModuleHandle)
If ReturnVal  0 Then
EnvFileName = ModuleHandle
TestEnvironment = True
Exit For
End If
Next
End Function

Private Sub Command1_Click()
If TestEnvironment() = True Then
MsgBox ("Running under IDE")
Else
MsgBox ("Running as EXE")
End If
End Sub

Another way to do is to detect whether the Visual Studio 6 IDE open or not using some API.

References Link
Question: How can I test whether a program is running at design time or run time using VB6?

Microsoft Codename

Drag: Moved from Old Blog

Microsoft codenames are the codenames given by Microsoft for their products before releasing
Thank you for giving me the useful links, Amiake-San!!! :-)

Informations related to Code-Name of Microsoft’s Product

Visual Studio .NET 2003
Everett is the code-name of Visua Studio .NET 2003. Actually, Everett is the name of city located 30 miles away from the the headquarter of Microsoft in “Redmond”, Washington State.

Links
Everett, Washington
Map – Goggle

Visual Studio .NET 2005
Whidbey is the code-name of Visua Studio .NET 2005. Whidbey is the name of an island floating on the Puget Sound, the opposite shore of Everett.

More Informations
Microsoft codenames

http://bink.nu/Codenames.bink

http://www.dnjonline.com/articles/backend/codenames.asp

IIS 6 – Virtual Directories Management with C#

Drag Article : Moved from Old Blog

C# – Visual Studio 2003
Programmatically Creating Virtual Directory and Deleting the Existing Virtual Directory on IIS 6.0?

#region Create Virtual Directory
/*
* Usage : CreateVirtualDirectory("localhost","MyWebApplication");
*
*/
public static bool CreateVirtualDirectory(string sWebSite,string sAppName,string sPath)
{
System.DirectoryServices.DirectoryEntry iISSchema = new System.DirectoryServices.DirectoryEntry("IIS://" + sWebSite + "/Schema/AppIsolated");
bool bCanCreate = !( iISSchema.Properties["Syntax"].Value.ToString().ToUpper() == "BOOLEAN");
iISSchema.Dispose();

if(bCanCreate)
{
bool bPathCreated=false;
try
{
System.DirectoryServices.DirectoryEntry iISAdmin = new System.DirectoryServices.DirectoryEntry("IIS://" + sWebSite + "/W3SVC/1/Root");

//make sure folder exists
if(! System.IO.Directory.Exists(sPath))
{
System.IO.Directory.CreateDirectory(sPath);
bPathCreated = true;
}

//If the virtual directory already exists then delete it
foreach(System.DirectoryServices.DirectoryEntry vd in iISAdmin.Children)
{
if(vd.Name==sAppName)
{
//iISAdmin.Invoke("Delete", new string(){vd.SchemaClassName,AppName};);
iISAdmin.Invoke("Delete", new string[]{vd.SchemaClassName, sAppName});
iISAdmin.CommitChanges();
break;
}
}

//Create and setup new virtual directory
System.DirectoryServices.DirectoryEntry vdir = iISAdmin.Children.Add(sAppName, "IIsWebVirtualDir");

vdir.Properties["Path"][0] = sPath;
vdir.Properties["AppFriendlyName"][0] = sAppName;
vdir.Properties["EnableDirBrowsing"][0] = false;
vdir.Properties["AccessRead"][0] = true;
vdir.Properties["AccessExecute"][0] = true;
vdir.Properties["AccessWrite"][0] = false;
vdir.Properties["AccessScript"][0] = true;
vdir.Properties["AuthNTLM"][0] = true;
vdir.Properties["EnableDefaultDoc"][0] = true;
vdir.Properties["DefaultDoc"][0] = "default.htm,default.aspx,default.asp";
vdir.Properties["AspEnableParentPaths"][0] = true;
vdir.CommitChanges();

//'the following are acceptable params
//'INPROC = 0
//'OUTPROC = 1
//'POOLED = 2
vdir.Invoke("AppCreate", 1);

return true;
}
catch(Exception ex)
{
if(bPathCreated)
{
System.IO.Directory.Delete(sPath);
throw ex;
}
}
}
return false;
}
#endregion

#region Delete Virtual Directory
/*
* Usage : DeleteVirtualDirectory("localhost","MyWebApplication");
*
*/
public static bool DeleteVirtualDirectory(string sWebSite,string sAppName)
{
System.DirectoryServices.DirectoryEntry iISSchema = new System.DirectoryServices.DirectoryEntry("IIS://" + sWebSite + "/Schema/AppIsolated");
bool bCanCreate = !( iISSchema.Properties["Syntax"].Value.ToString().ToUpper() == "BOOLEAN");
iISSchema.Dispose();

if(bCanCreate)
{
try
{
System.DirectoryServices.DirectoryEntry iISAdmin = new System.DirectoryServices.DirectoryEntry("IIS://" + sWebSite + "/W3SVC/1/Root");

string sWebPath = iISAdmin.Properties["Path"].Value.ToString();

//If the virtual directory already exists then delete it
foreach(System.DirectoryServices.DirectoryEntry vd in iISAdmin.Children)
{
if(vd.Name==sAppName)
{
sWebPath += "\" + vd.Name;

//if(((System.DirectoryServices.PropertyCollection)((vd.Properties))).valueTable.Count > 0 )
//Original = IIsWebDirectory
//Custom = IIsWebVirtualDir
if(vd.Properties["KeyType"].Value.ToString().Trim() == "IIsWebVirtualDir")
sWebPath=vd.Properties["Path"].Value.ToString();

//iISAdmin.Invoke("Delete", new string(){vd.SchemaClassName,AppName};);
iISAdmin.Invoke("Delete", new string[]{vd.SchemaClassName, sAppName});
System.IO.Directory.Delete(sWebPath);
iISAdmin.CommitChanges();
return true;
}
}
}
catch(Exception ex)
{
return false;
}
}
return false;
}
#endregion

Some other informations related to IIS & .NET 2003

Create a Virtual Directory and Edit its Properties in IIS using C# http://dotnetjunkies.com/WebLog/ramdash/articles/21777.aspx

Create Virtual Directory in IIS using VB.NET
http://www.vbforums.com/printthread.php?t=347207

Create Virtual Directory in IIS using C# [Easy Way]

System.EnterpriseServices.Internal.IISVirtualRoot vr = new System.EnterpriseServices.Internal.IISVirtualRoot();
string sErr=null;
vr.Create("IIS://localhost/W3SVC/1/Root",@"C:Sync\","WebServices",out sErr);
Console.WriteLine(sErr);

Virtual Directory
http://www.c-sharpcorner.com/Code/2002/July/CreateVirtualDirs.asp

Creating your own Web Server using C#
http://www.c-sharpcorner.com/Internet/CreatingWebServerInCSIMA.asp

*******

To help a person who don’t know about creating IIS. esp: beginner. :-)

[Using INetMgr]
===============

IIS Applications and Virtual Directories
http://authors.aspalliance.com/PaulWilson/Articles/?id=16

How to: Create and Configure Virtual Directories in IIS
http://msdn2.microsoft.com/en-us/library/zwk103ab.aspx

Internet Information Services (IIS) 6.0 Resource Kit http://www.microsoft.com/downloads/details.aspx?FamilyID=80a1b6e6-829e-49b7-8c02-333d9c148e69&DisplayLang=en

How To Install MetaEdit 2.2 on Windows NT 4.0 or Windows 2000?
If you wanna know about IIS in deep, you should install this exe. This tool will let you know about IIS structures such as where IIS store all information about web folder. I would say that it’s really interesting tool. Enjoy :-) http://support.microsoft.com/default.aspx?scid=kb;en-us;301386&sd=tech
Hints :
What is MetaEdit 2.2?
MetaEdit 2.2 is designed to help administer Microsoft® Internet Information Server for Windows NT® Server 4.0, and Microsoft® Internet Information Services for Windows 2000®.

What is the Metabase?
The metabase is a hierarchical database that is used to store configuration values for IIS. In previous versions of IIS, such values were configurable by directly editing the registry. Some values are still configurable by editing the registry, but the metabase provides more granularity in the configuration of server properties. You can set server properties at the computer, Web site, virtual directory, directory, and file level by modifying the metabase.

Outlook Tips : To prevent sending mails without mentioning ’subject’

To prevent sending mails without mentioning ‘subject’ use this code.

Steps – Open you outlook, press ALT+F11. On left pane in ‘Microsoft Outlook objects’, expand to see ‘This outlook session’. Double click to open the editor. Copy and paste the following code and save the session.

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim strSubject As String
    strSubject = Item.Subject
    If Len(strSubject) = 0 Then
       Prompt$ = "Subject is Empty. Are you sure you want to send the Mail?"
       If MsgBox(Prompt$, vbYesNo + vbQuestion + vbMsgBoxSetForeground, "Check for Subject") = vbNo Then
             Cancel = True
       End If
   End If
End Sub