// This helper function retrieve active Dll Major version number // private CANResult DllMajorVersion(HardwareType hType, out int majorVersion) { CANResult Res; String dllVersionStr = ""; // We execute the "DllVersionInfo" function of the PCANLight // using as parameter the Hardware type and a string // variable to get the info like "x.xx" // Res = PCANLight.DllVersionInfo(hType, out dllVersionStr); // We retrieve major version number // spliting versionNumberStr based on "." decimal symbol // String[] versionTabInfo = dllVersionStr.Split('.'); if (versionTabInfo.Length > 0) { Int32.TryParse(versionTabInfo[0].ToString(), out majorVersion); } else { majorVersion = 0; } return(Res); }
private void btnDllInfo_Click(object sender, EventArgs e) { String strInfo = ""; CANResult Res; // We execute the "VersionInfo" function of the PCANLight // using as parameter the Hardware type and a string // variable to get the info. // Res = PCANLight.DllVersionInfo((HardwareType)cbbHws.SelectedIndex, out strInfo); // The function was successfully executed // if (Res == CANResult.ERR_OK) { // We show the Version Information // strInfo = strInfo.Replace("\n", "\r\n"); strInfo = cbbHws.SelectedItem.ToString() + " Dll Version: " + strInfo; txtInfo.Text = strInfo; } // An error occurred. We show the error. // else { txtInfo.Text = "Error: " + String.Format("{0:X4}", (int)Res); } }