Monday, April 28, 2014

VC++ 6.0 include file

In windows explorer just from the source root directory doing an up arrow to go to the command directory that other include uses, so you count the number of "..\" needed

Ex. your project is at

F:\tfs\aaa\bbb\ccc\ddd

then your include file is at
F:\tsf\eee\fff\ggg\hhh

then you need to open F:\tfs\aaa\bbb\ccc\ddd in windows explorer, count backup 4 times to get to F:\tfs
then your include file is 

#include "..\..\..\..\eee\fff\ggg\hh\filename.h"

Sunday, April 27, 2014

Javascript load Window load

http://www.codeproject.com/Tips/632672/JavaScripts-document-ready-vs-window-load

Thursday, April 24, 2014

using Qunit

http://qunitjs.com/

https://qunitjs.com/cookbook/

Log4Net include DLL log

You can put DLL logger name  in the same conf file and log will go to the same log file (see below you have two logger names, the 2nd if from the DLL )


  <logger name="FirstAppLogger">
      <level value="ALL" />
      <appender-ref ref="ExampleAppender" />
    </logger>
    <logger name="DLLLogger">
      <level value="ALL" />
      <appender-ref ref="ExampleAppender" />
    </logger>

Wednesday, April 23, 2014

Tuesday, April 22, 2014

vbscript copy files from a folder

dim objFolder
dim sFolderName
dim objFiles
dim objFile
Set objFSO = CreateObject("Scripting.FileSystemObject")
sFolderName = "E:\Program Files\Indicator Files\OCDInfo\"
if (objFSO.FolderExists(sFolderName)) then

 set objFolder = objFSO.GetFolder(sFolderName)
 set objFiles = objFolder.Files
  For each objFile in objFiles
   objFSO.CopyFile objFile.Path, "E:\dest\" & objFile.name
 Next
else
end if

Using Git with Visual Studio 2013 Jump Start

http://www.microsoftvirtualacademy.com/training-courses/using-git-with-visual-studio-2013-jump-start

01 skip everything till about 13:09

Friday, April 18, 2014

Dynamically load DLL

  Dim myDllLoaded As DLLWrapper
   Dim oDll As DLLWrapper = New DLLWrapper(sTypeName, sDLLName, sDLLFilePath)

     If myDllLoaded IsNot Nothing Then
                                            ' Activate method in the DLL for processing email
                                            If Not myDllLoaded.ActivatedOnce Then
                                                If Not myDllLoaded.ActivateDLLType() Then
                                                    Throw New Exception(String.Format("Not able to load DLL {0}", oEmailType.TypeName))
                                                End If
                                            End If
                                            If myDllLoaded.ActivatedOnce Then
                                                Dim aryEmail(0) As WenOutlookEmail
                                                aryEmail(0) = myEmail
                                                ' Process each email
                                                If myDllLoaded.ProcessTasks(aryEmail) Then
                                                    ' Delete email after it has been processed successfull

The class below called DLLWrapper

Imports System.Reflection
Imports System.IO
Imports System.Xml
''' <summary>
''' Wrapper to get all necessary information to load DLL and activate method of DLL.
''' </summary>
Public Class DLLWrapper

#Region "Constants"
    Private Const METHOD_NAME As String = "MyMethod_in_DLL"
#End Region

#Region "Attributes"
    Private m_bActivatedOnce As Boolean
    Private m_iTryToActivateCount As Integer
    Private m_oAssembly As Assembly
    Private m_sTypeName As String
    Private m_sDLLName As String
    Private m_sDLLFilePath As String
    Private m_oType As Object
    Private m_oMethodInfo As MethodInfo
    Private m_oDLL As Object
#End Region

#Region "Properties"
    Public ReadOnly Property ActivatedOnce() As Boolean
        Get
            Return m_bActivatedOnce
        End Get
    End Property
#End Region

#Region "Public methods"

    Public Sub New(ByVal sTypeName As String, ByVal sDLLName As String, ByVal sDllFilePath As String)
        Dim sClassAndMethodName As String = String.Empty
        Dim sFullName As String
        Try
            m_bActivatedOnce = False
            m_iTryToActivateCount = 0
            m_sTypeName = String.Empty
            m_sDLLName = String.Empty
            m_sDLLFilePath = String.Empty
            Dim oAssemblyName As AssemblyName = New AssemblyName(sDLLName)
            oAssemblyName.CodeBase = sDllFilePath
            m_oAssembly = Assembly.Load(oAssemblyName)
            sFullName = sTypeName
            m_oType = m_oAssembly.GetType(sFullName)
            m_oMethodInfo = m_oType.GetMethod(METHOD_NAME, New Type() {GetType(myDLLObject)})
        Catch ex As Exception
        End Try

    End Sub

    ''' <summary>
    ''' Invoke method in DLL to process.
    ''' </summary>
    ''' <param name="aryEmail">The array of email object.</param>
    ''' <returns></returns>
    Public Function ProcessTasks(ByVal aryObj() As myDLLObject) As Boolean // all DLL has the same method name ProcessTasks
        Dim bRc As Boolean = False
        Try
            If m_oMethodInfo.Invoke(m_oDLL, aryObj) Then // calls MyMethod_in_DLL in each DLL(dynamiclly loaded) and pass aryObj
                bRc = True
            End If
        Catch ex As Exception
        End Try
        Return bRc
    End Function

    ''' <summary>
    ''' Activates(creates) an instance of the DLL
    ''' </summary>
    ''' <returns></returns>
    Public Function ActivateDLLType() As Boolean
        Dim bRC As Boolean = False
        Try
            If Not m_bActivatedOnce Then
                m_oDLL = Activator.CreateInstance(m_oType, xxxxx) //xxxxx is the parm for new() method, it could be a logger object
                If m_oDLL IsNot Nothing Then
                    m_bActivatedOnce = True
                    bRC = True
                End If
            End If
        Catch ex As Exception
        End Try
        Return bRC
    End Function
#End Region

End Class

entry point not found

One main app dynamically load DLL from hard drive and  that DLL has a logger DLL, when it get to the logger to write out logs, first logging was fine, but the next I got "entry not found" error. I found that the  main app and the called DLL both have the logger DLL but with different versions. After make them the same version this entry not found error fixed.

install git

https://chocolatey.org/

open command prompt
@powershell -NoProfile -ExecutionPolicy unrestricted -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%systemdrive%\chocolatey\bin

opon windows powershell  (type powershell in windows search box)
type
cinst poshgit
type
cinst git-credential-winstore

You have to open powershell as administrator to run the step below
type
set-executionpolicy remotesigned
restart powershell you will get ssh-agent not found error
add C:\Program Files (x86)\Git\bin to path, then it will ask for pass phrase, enter that
http://haacked.com/archive/2011/12/19/get-git-for-windows.aspx/

git config --global user.name "Greg Chu"
git config --global user.email "chu_greg@xxxx.com"
git config --global core.editor notepad.exe


Thursday, April 17, 2014

VB.net C# Run a bat file or a DOS command prompt

C# examples => http://csharptest.net/532/using-processstart-to-capture-console-output/

Some are global "m_xxxx" variables. You can add by yourself.

''' <summary>
    ''' Run a bat file or a DOS command
    ''' </summary>
    Public Function ExecTask(ByVal sCmd As String, ByVal sArgs As String) As String
        Dim sResult As String = String.Empty
        Dim oProcess As New Process
        Dim oStartInfo As New ProcessStartInfo
        Dim sAppPath As String = String.Empty
        Dim sCmdFull As String = String.Empty
        Dim sMethod As String = m_sClassName & "." & MethodBase.GetCurrentMethod().Name
        Try
            LogMsg(String.Format("Enter, cmd={0}, args={1}", sCmd, sArgs))
            m_sOutput = New StringBuilder
            sCmdFull = sCmd & " " & sArgs
            LogMsg(String.Format("Enter, full cmd={0}", sCmdFull))
            With oStartInfo
                .Arguments = sArgs
                .FileName = sCmd
                .RedirectStandardError = True
                .RedirectStandardOutput = True
                .UseShellExecute = False
                .WindowStyle = ProcessWindowStyle.Hidden
            End With

            oProcess = Process.Start(oStartInfo)
            AddHandler oProcess.OutputDataReceived, AddressOf OutPutDataReceived 'asynchronously read output to prevent deadlock
            oProcess.BeginOutputReadLine()
            m_sError = oProcess.StandardError.ReadToEnd
            oProcess.WaitForExit()
        Catch ex As Exception
            LogMsg(String.Format("Exception {0}", ex.Message))
            m_sError = ex.Message
            m_ErrorList.Add(sMethod & ex.Message)
        Finally
            LogMsg(String.Format("Standard output={0}", m_sOutput.ToString.Trim))
            LogMsg(String.Format("Standard Error={0}", m_sError))
            oProcess.Close()
            oProcess.Dispose()
        End Try
        If m_sError > String.Empty Then
            'Return sPath & " Error: " & m_sError
            Return " Error: " & m_sError
        Else
            Return m_sOutput.ToString
        End If

    End Function

 '
    ' to get the standard output from command line execution of net use
    '
    Private Sub OutPutDataReceived(ByVal sender As Object, ByVal e As DataReceivedEventArgs)
        m_sOutput.Append(e.Data)
    End Sub

Friday, April 11, 2014

vb6 command line arguments

When you debug VB6 you set command line arguments in project properties.




Friday, April 4, 2014

Convert vbscript code to vb.net

Create vb.net console project

below blue is old vbscript, yellow is converted code

Add reference to Interop.IWshRuntimeLibrary

Imports IWshRuntimeLibrary

 'objFSO = CreateObject("Scripting.FileSystemObject")

Dim objFSO As FileSystemObject = New FileSystemObject

 ' WshNetwork = WScript.CreateObject("WScript.Network")

 Dim WshNetwork As WshNetwork = New WshNetwork

move  two yellow lines below to above Main to make it globally accessible

Module Module1
    Dim objFSO As FileSystemObject = New FileSystemObject
    Dim WshNetwork As WshNetwork = New WshNetwork
    Sub Main()

may want to change objFSO to m_objFSO and WshNetwork to m_wshNetwork

InstallShield: cannot extract icon with index 0

In setup project select "Project Assistant", then select 1) Application shortcuts, then 2) browse to add an icon 3) ico file added

You build again and should resolve this error.

To create an icon, link below has good suggestions.

http://myappmag.com/make-windows-icons/

Wednesday, April 2, 2014

Developing in HTML5 with JavaScript and CSS3 Jumpstart self accessment answer key (Microsoft virtual academy)


http://microsoftnotes.wikispaces.com/Section+1+HTML5+Semantic+Structure
If complex, SVG will be slow in rendering.

You can mark a field as required in an input form by either using a bare required attribute or setting a required attribute equal to required.
For example: <input type="text" required /> or <input type="text" required="required"

SVG images can be searched within a DOM.

Figure is the Semantic tag for grouping stand-alone content. Like video or image.

Footer is the Semantic tag for Providing author, copyright data.