I have two barcode scaners - MC9090 and MC9190. Initially under the MC9090 has been written application that reads barcodes and work with SQL databases.On the MC9090 everything works fine on the MS9190 - problem - not read the barcode type I2OF5 (length = min - 6, max - 8 respectively). Modify the default values (14 and 10 respectively) with the help of a piece of code (on MC9090):
myReader.Decoders.I2OF5.MinimumLength = 6;
myReader.Decoders.I2OF5.MaximumLength = 8;
With MC9190 I can read I2OF5 barcodes with default parameters(14 and 10 respectively), but I cant read I2OF5 barcodes with lenght min = 6, max = 8.
Tried to send the complete list of parameters like this (already on MC9190):
myReader.Parameters.CodeIdType = CodeIdTypes.None;
myReader.Parameters.ScanType = ScanTypes.Foreground;
myReader.Decoders.I2OF5.MinimumLength = 6;
myReader.Decoders.I2OF5.MaximumLength = 8;
myReader.Decoders.I2OF5.Redundancy = true;
myReader.Decoders.I2OF5.CheckDigitScheme = I2OF5.CheckDigitSchemes.None;
myReader.Decoders.I2OF5.ConvertToEAN13 = false;
myReader.Decoders.I2OF5.ReportCheckDigit = false;
myReader.Actions.SetParameters();
With these parameters, barcodes are read in the demo applications Motorola's great, but not in mine app.
I do check like this:
if (_scnAPI.Reader.Decoders.I2OF5.Enabled == true)
{
if (_scnAPI.Reader.Decoders.I2OF5.MinimumLength == 6)
{
MessageBox.Show("6");
}
if (_scnAPI.Reader.Decoders.I2OF5.MaximumLength == 8)
{
MessageBox.Show("8");
}
if (_scnAPI.Reader.Decoders.I2OF5.Redundancy == true)
{
MessageBox.Show("Redundancy");
}
if (_scnAPI.Reader.Parameters.CodeIdType == Symbol.Barcode.CodeIdTypes.None)
{
MessageBox.Show("CodeType");
}
if (_scnAPI.Reader.Decoders.I2OF5.CheckDigitScheme == Symbol.Barcode.I2OF5.CheckDigitSchemes.None)
{
MessageBox.Show("CheckDigit");
}
if (_scnAPI.Reader.Parameters.ScanType == Symbol.Barcode.ScanTypes.Foreground)
{
MessageBox.Show("foreground");
}
}
else
{
MessageBox.Show("App Exit!");
Application.Exit();
}
All checks are passed, but it is not clear why there is no reading I2OF5 barcodes with the right length to me? Please help me figure out what the problem is.
P.S.
I use the library Symbol.Barcode, Motorola EMDK 2.4 for .NET. I looked specification of EMDK 2.4 version is compatible with the 9100- series.
https://atgsupportcentral.motorolasolutions.com/content/emb/docs/ReleaseNotes/Release%20Notes%20-%20EMDK-M-020403TnV1.htm
My experience: Code128 barcode settings blocked the I2OF5 reading.
public FormMain()
{
bcl.OnScan +=new Barcode2.OnScanHandler(bcl_OnScan);
bcl.Config.Decoders.I2OF5.Enabled = true;
bcl.Config.Decoders.CODE128.Enabled = false;
bcl.Config.Decoders.I2OF5.MinLength = 6;
bcl.Config.Decoders.I2OF5.MaxLength = 8;
bcl.Scan();
InitializeComponent();
}
Disable the CODE128, enable the I2OF5, and set the parameters of I2OF5. It workes for me!
Related
I read a lot of stackoverflow post, but there was no solution for my problem.
I want to get the version number of the running Windows 10 installation (e.g. 1809 or 1909) in C# or WinJS
I develop an UWP app with Cordova (Javascript) and I have also a Cordova plugin (winmd) in C# which I can use, but there is no api to get this 4 digit version number.
I have a WinJS/Javascript code which was working fine till version 1903:
var ApiInformation = Windows.Foundation.Metadata.ApiInformation;
if (ApiInformation.isApiContractPresent("Windows.Foundation.UniversalApiContract", 9)) {
return 9999; // TODO: fix this build number, when it is released
} else if (ApiInformation.isApiContractPresent("Windows.Foundation.UniversalApiContract", 8)) {
return 1903;
} else if (ApiInformation.isApiContractPresent("Windows.Foundation.UniversalApiContract", 7)) {
return 1809;
} else if (ApiInformation.isApiContractPresent("Windows.Foundation.UniversalApiContract", 6)) {
return 1803;
} else if (ApiInformation.isApiContractPresent("Windows.Foundation.UniversalApiContract", 5)) {
return 1709
} else if (ApiInformation.isApiContractPresent("Windows.Foundation.UniversalApiContract", 4)) {
return 1703;
} else if (ApiInformation.isApiContractPresent("Windows.Foundation.UniversalApiContract", 3)) {
return 1607;
} else if (ApiInformation.isApiContractPresent("Windows.Foundation.UniversalApiContract", 2)) {
return 1511;
} else if (ApiInformation.isApiContractPresent("Windows.Foundation.UniversalApiContract", 1)) {
return 1507;
} else {
return 0;
}
But because Windows 10 1909 is only a bugfix version with no own SDK, there is also no new UniversalApiContract version. So on a Windows 1909 installation the check for UniversalApiContract "9" returns "false" and so it returns "1903" instead "1909".
Are there some developers out there, who find out something in version 1909, which is new or unique to 1909, so we can check for this and say that this is version 1909?
Important: I am developing an UWP app and Windows has a sandbox concept for UWP apps, so there are some limitations, e.g. UWP apps cannot access the registry or the whole filesystem.
[UPDATE]
Thanks Peter! It works now.
I use it in UWP Cordova WinJS/Javascript with this code:
var v = Windows.System.Profile.AnalyticsInfo.versionInfo.deviceFamilyVersion;
var major = (v & 0xFFFF000000000000) >> 48;
var minor = (v & 0x0000FFFF00000000) >> 32;
var build = (v & 0x00000000FFFF0000) >> 16;
var release = v & 0x000000000000FFFF;
if (build == 18363)
return 1909;
if (build == 18362)
return 1903;
I had to use Windows.System.Profile.AnalyticsInfo.versionInfo.deviceFamilyVersion, because Windows.System.Profile.AnalyticsVersionInfo.deviceFamilyVersion was "undefined" with the hint "Permission denied"? But the code above works.
You can use AnalyticsInfo.VersionInfo.DeviceFamilyVersion to get the version number.
The property is a string which contains some digits. Parse the string into a 32-bit number, and then each byte of that 32-bit number forms part of a standard A.B.C.D version.
It looks like most of the information is available from Environment.OSVersion, except for the release number. Adapting technique from the other answers and combining, you can do this:
using System;
using Windows.System.Profile;
public static Version GetWindowsVersion()
{
var v = Environment.OSVersion.Version;
var release = (int) ulong.Parse(AnalyticsInfo.VersionInfo.DeviceFamilyVersion) & 0xffff;
return new Version(v.Major, v.Minor, v.Build, release);
}
i am new to WIA. And i have been asked to make scaning service scan faster and duplex. My current service scan one page, then put it in pdf and so on untill there is less then 20 pages(this number just a crutch used before me, will be glad if someone explane how to get "if there is any paper in there" variable). I started to dig and found docs on MSDN describing properties and after found this post describing duplex sanning, but with mysterious 5 in set. After I found this and figured out what i need WIA_DPS_DOCUMENT_HANDLING_SELECT to set to 0x205(FEEDER + DUPLEX + AUTO_ADVANCE). So I tried to setup them like this:
private static void SetProperty(Property property, int value)
{
IProperty x = (IProperty)property;
Object val = value;
x.set_Value(ref val);
}
...some code...
foreach (Property prop in device.Properties)
{
//LOGGER.Warn(prop.Name);
//LOGGER.Warn(prop.PropertyID);
switch ((Int32)prop.PropertyID)
{
// Document Handling Select
case 3088:
SetProperty(prop, 517);
break;
// Pages
case 3096:
SetProperty(prop, 1);
break;
}
}
And it did't worked for me... It just stuck on setting... Can Somebody explain how to setup AUTO_ADVANCE and DUPLEX props? Or maybe "make scanning faster and duplex" need something more then just AUTO_ADVANCE and DUPLEX and my perception about them is wrong? Or I should considering "ISIS / TWAIN (Windows XP / Vista / 7 / 8 / 8.1 / 10)" string in my scan description and use other libraries?
(Window 10, Canon DR-M160||, DR-M160 & DR-M160II Driver for Windows)
and also here is the current fetch function:
public List<ImageFile> FetchImageList()
{
List<ImageFile> imageList = new List<ImageFile>();
//bool hasMorePages = true;
int testcount = 0;
while (testcount >= 0)
{
testcount--;
WIA.Device device = FindDevice(_deviceId);
if (device == null)
{
LOGGER.Warn("Scanner device not found");
return null;
}
// get item
WIA.Item scanItem = device.Items[1] as WIA.Item;
LOGGER.Debug($"ScanItem: {scanItem.ItemID}");
try
{
foreach (Property prop in device.Properties)
{
//LOGGER.Warn(prop.Name);
//LOGGER.Warn(prop.PropertyID);
switch ((Int32)prop.PropertyID)
{
// Document Handling Select
case 3088:
LOGGER.Warn("here");
SetProperty(prop, 517);
LOGGER.Warn("here");
break;
// Pages
case 3096:
SetProperty(prop, 1);
break;
}
}
// scan image
WIA.ICommonDialog wiaCommonDialog = new WIA.CommonDialog();
WIA.ImageFile image = (WIA.ImageFile)scanItem.Transfer(WIA.FormatID.wiaFormatPNG);
imageList.Add(image);
LOGGER.Warn("Front");
//get back side
image = (WIA.ImageFile)scanItem.Transfer(WIA.FormatID.wiaFormatPNG);
imageList.Add(image);
LOGGER.Warn("Back");
}
catch (Exception e)
{
throw (e);
}
}
return imageList;
}
Well... I tried to make duplex scan without AUTO_ADVANCE and got HRESULT: 0x8000FFFF (E_UNEXPECTED) on Transfer call. According to this post(even though that was on Windows 7) I guess there is no way to solve this for me by using WIA, still hope there will other suggestions...
Solved problem
I used saraff.twain and it worked for me:
- git page :https://github.com/saraff-9EB1047A4BEB4cef8506B29BA325BD5A/Saraff.Twain.NET
good library with grate wiki page.(Also have similar library for .net 4.6.1)
I have an application that is using an smart card reader for allowing the users to access parts of the system. On one location i have no issues. But another, which have an different type of card manufacturer has a lot of issues. It keeps getting an id of zero back. Then looking into the eventlog i saw this:
And this is the code:
card.Connect(reader, SHARE.Shared, PROTOCOL.T0orT1);
var apduGetID = new APDUCommand(0xFF, 0xCA, 0, 0, null, 4);
var apduRespGetID = card.Transmit(apduGetID);
long cardId = BitConverter.ToUInt32(apduRespGetID.Data.Reverse().ToArray(), 0);
the second problem is that then trying to debug the code, it works perfect, only then remove the breakpoint can i see the issue but not where. Can some one please help me?
P.S. i found this thread, but it does not work: https://superuser.com/questions/715688/smart-card-errors
Update: Here are the Transmit class
public override APDUResponse Transmit(APDUCommand ApduCmd)
{
var RecvLength = (uint)(ApduCmd.Le + APDUResponse.SW_LENGTH);
byte[] ApduBuffer;
var ApduResponse = new byte[ApduCmd.Le + APDUResponse.SW_LENGTH];
var ioRequest = new SCard_IO_Request
{
m_dwProtocol = m_nProtocol,
m_cbPciLength = 8
};
// Build the command APDU
if (ApduCmd.Data == null)
{
ApduBuffer = new byte[APDUCommand.APDU_MIN_LENGTH + ((ApduCmd.Le != 0) ? 1 : 0)];
if (ApduCmd.Le != 0)
{
ApduBuffer[4] = ApduCmd.Le;
}
}
else
{
ApduBuffer = new byte[APDUCommand.APDU_MIN_LENGTH + 1 + ApduCmd.Data.Length];
for (var nI = 0; nI < ApduCmd.Data.Length; nI++)
{
ApduBuffer[APDUCommand.APDU_MIN_LENGTH + 1 + nI] = ApduCmd.Data[nI];
}
ApduBuffer[APDUCommand.APDU_MIN_LENGTH] = (byte)ApduCmd.Data.Length;
}
ApduBuffer[0] = ApduCmd.Class;
ApduBuffer[1] = ApduCmd.Ins;
ApduBuffer[2] = ApduCmd.P1;
ApduBuffer[3] = ApduCmd.P2;
m_nLastError = SCardTransmit(m_hCard, ref ioRequest, ApduBuffer, (uint)ApduBuffer.Length, IntPtr.Zero, ApduResponse, out RecvLength);
if (m_nLastError != 0)
{
var msg = "SCardTransmit error: " + m_nLastError;
throw new SmartCardException(msg, m_nLastError);
}
var apduData = new byte[RecvLength];
for (var nI = 0; nI < RecvLength; nI++)
{
apduData[nI] = ApduResponse[nI];
}
return new APDUResponse(apduData);
}
Update 2: I have also tried with to put some Thread.Sleep()
Please check that on the second machine you have all the up-to-date drivers of the smart card. Also, sometimes it helps to replace the driver which is provided by the manufacturer with "Microsoft WUDF driver" - https://msdn.microsoft.com/en-us/library/windows/hardware/dn653571(v=vs.85).aspx
Please note, that you have two type of devices detected by the OS when you plug it in - the smart card enumerator device (smart card reader) and the smart card (sometimes called the smart card container) itself. One smart card reader can contain several smart cards.
Example of the smart card which driver was forcefully replaced with Microsoft WUDF to make the client application (iBank2) work:
The four smart card drivers have been forcefully replaced with basic Microsoft driver to make the application work.
Well if the other system does not take your smart card,just check the BIOS settings for smartcard.There is an option to disable/enable them in some systems.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 8 years ago.
Improve this question
I am new to C# programming. I have a program that I modified in C, I now need to take the string array that I get from my C program and pass it to a C# program so that it can query an Oracle database using those values.
This program is used to get the serial numbers from all of the iButton devices connected to the computer.
Here is the C code
// function prototypes
void UnLoadTMEX(void);
short LoadTMEX(void);
// globals
static FARPROC Get_Version, TMGetTypeVersion, TMEndSession;
static FARPROC TMSetup, TMNext, TMRom, ExtendedStartSession;
static FARPROC TMReadDefaultPort;
long (__fastcall *TMExtendedStartSession)(short,short,void *);
static HINSTANCE hInst;
unsigned char state_buf[5125];
//--------------------------------------------------------------------------
// Main of iSerial64
//
void main(int argc, char **argv)
{
char refresh,buf[200];
short flag,i,didsetup=0;
short ROM[9];
short PortNum,PortType;
long SHandle;
char serialtmp[2], serial[10][17];
int j = -1;
// load the TMEX driver and get pointers to functions
if (!LoadTMEX())
{
printf("ERROR, could not load IBFS64.DLL\n");
exit(0);
}
// load the TMEX driver and get pointers to functions
TMReadDefaultPort(&PortNum, &PortType);
// get the TMEX driver version
printf("Port number: %d Port type: %d\n",PortNum,PortType);
Get_Version(buf);
printf("Main Driver: %s\n",buf);
printf("TYPE%d:",PortType);
if ((short)TMGetTypeVersion(PortType,buf) < 0)
{
printf("\nNo Hardware Driver for this type found!\n");
// Unload the TMEX driver
UnLoadTMEX();
exit(0);
}
printf(" %s\n\n\n",buf);
// check the command line
if (argc > 1)
PortNum = atoi(argv[1]);
// check for valid range of PortNum
if ((PortNum < 1) || (PortNum > 15))
{
printf("ERROR, invalid port requested: %d\n",PortNum);
exit(0);
}
// loop to display the rom numbers until key hit
do
{
// get a session handle to the requested port
SHandle = TMExtendedStartSession(PortNum,PortType,NULL);
if (SHandle > 0)
{
// check to see if TMSetup has been done once
if (!didsetup)
{
flag = (short)TMSetup(SHandle);
if (flag == 1 || flag == 2)
{
printf("TMSetup complete %d\n",flag);
didsetup = 1;
}
else
{
printf("ERROR doing setup %d\n",flag);
break;
}
}
// only get the next rom after setup complete
else
{
//j was added to keep track of the serial number strings
j++;
memset(serial[j], 0, strlen(serial[j]));
flag = (short)TMNext(SHandle,(void far *)&state_buf[0]);
if (flag > 0)
{
ROM[0] = 0;
flag = (short)TMRom(SHandle, (void far *)&state_buf[0], (short far *)&ROM[0]);
for (i = 7; i >= 0; i--)
{
//This section was changed from the original
//copies raw number into string
sprintf(serialtmp, "%02X", ROM[i]);
strcat(serial[j], serialtmp);
}
printf("%s ", serial[j]);
printf("\n");
}
else
printf("end of search\n");
}
// close the opened session
TMEndSession(SHandle);
}
}
while (flag > 0);
// Unload the TMEX driver
UnLoadTMEX();
printf("iSERIAL64 end\n");
}
//--------------------------------------------------------------------------
// Load the TMEX driver and get a pointers to the functions
//
short LoadTMEX(void)
{
// attempt to get a SHandle to the TMEX driver
hInst = LoadLibrary(L"IBFS64.DLL");
// get a pointer to the function needed by loopit64
if (hInst != NULL)
{
ExtendedStartSession = GetProcAddress(hInst,"TMExtendedStartSession");
TMEndSession = GetProcAddress(hInst,"TMEndSession");
TMSetup = GetProcAddress(hInst,"TMSetup");
TMNext = GetProcAddress(hInst,"TMNext");
TMRom = GetProcAddress(hInst,"TMRom");
Get_Version = GetProcAddress(hInst,"Get_Version");
TMGetTypeVersion = GetProcAddress(hInst,"TMGetTypeVersion");
TMReadDefaultPort = GetProcAddress(hInst, "TMReadDefaultPort");
// check to make sure got ALL of the functions needed
if ((ExtendedStartSession == NULL) || (TMEndSession == NULL) ||
(TMSetup == NULL) || (TMNext == NULL) ||
(TMRom == NULL) || (Get_Version == NULL) ||
(TMGetTypeVersion == NULL) || (TMReadDefaultPort == NULL))
{
printf("ERROR, could not get a pointer to all"
" of the TMEX functions needed\n");
return 0;
}
// get a function pointer that returns a long
TMExtendedStartSession = (long (__fastcall *)(short,short,void *))ExtendedStartSession;
return 1;
}
else
return 0;
}
//--------------------------------------------------------------------------
// UnLoad the TMEX driver
//
void UnLoadTMEX(void)
{
// release the TMEX driver
FreeLibrary(hInst);
}
Should I attempt to convert this, or just create a C DLL and import that into my C# program? Like I said, I haven't really worked with C#, I'm an intern and my boss is giving me this project so that I can learn C#. Any help is greatly appreciated
If you want use c dll in c# read this article.
But is better that convert the code to c# code because you can manage this code and update the code easily.
If your boss is giving you this project to learn C#, I'd say go ahead and convert it to C#. It will make future use of the code a lot easier.
I'd recommend looking at the book C# in Depth for a good intro to C#.
Currently I develop a projekt in C#. In this project I use the DirectX API. Now I want to implement a function to check whether DirectX is available or not?
Do you have an idea how to do this?
Thank you for your help!
Do you need to detect if there's DirectX compatible GPU in the system, so that Direct3D9 device can be created, which is not the case with some virtual operating systems etc? That one can be tested simply by creating a device instance and catching the exception it possibly throws.
DirectX install existence itself can be checked by looking into Windows\System32 folder. For example, check d3d9d.dll, and D3DX9_43.dll.
Another way to get the DirectX - Version:
void CheckDirectXMajorVersion()
{
int directxMajorVersion = 0;
var OSVersion = Environment.OSVersion;
// if Windows Vista or later
if (OSVersion.Version.Major >= 6)
{
// if Windows 7 or later
if (OSVersion.Version.Major > 6 || OSVersion.Version.Minor >= 1)
{
directxMajorVersion = 11;
}
// if Windows Vista
else
{
directxMajorVersion = 10;
}
}
// if Windows XP or earlier.
else
{
using (RegistryKey key = Registry.LocalMachine.OpenSubKey(#"SOFTWARE\Microsoft\DirectX"))
{
string versionStr = key.GetValue("Version") as string;
if (!string.IsNullOrEmpty(versionStr))
{
var versionComponents = versionStr.Split('.');
if (versionComponents.Length > 1)
{
int directXLevel;
if (int.TryParse(versionComponents[1], out directXLevel))
{
directxMajorVersion = directXLevel;
}
}
}
}
}
Console.WriteLine("DirectX Version: " + directxMajorVersion.ToString());
Console.ReadKey();
}