USB x Paralela: DLL em VB6 para C#
19/07/2011
0
Ronaldo
Posts
21/07/2011
Marcio Silveira
Se essa sua dll é um objeto COM+ deveria funcionar normalmente no C#, basta fazer a referência.
21/07/2011
Ronaldo
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices; namespace paralela_usb
{
unsafe class paralela
{
[DllImport("RCOM_USB_LPT.dll")]
public static extern unsafe bool TestaBit(byte valor, byte bit);
[DllImport("RCOM_USB_LPT.dll")]
public static extern unsafe byte LigaBit(byte Valor, byte Bit);
[DllImport("RCOM_USB_LPT.dll")]
public static extern unsafe byte DesligaBit(byte Valor, byte Bit);
[DllImport("RCOM_USB_LPT.dll")]
public static extern unsafe int LPT_Abrir_Porta(string NomePorta);
[DllImport("RCOM_USB_LPT.dll")]
public static extern unsafe int LPT_WriteByte(long hDevice, byte pRegIndex, byte pRegValue);
[DllImport("RCOM_USB_LPT.dll" )]
public static extern unsafe byte LPT_ReadByte(long hDevice, byte pRegIndex);
[DllImport("RCOM_USB_LPT.dll" )]
public static extern unsafe bool CheckDriver(long hDevice);
[DllImport("kernel32")]
public static extern long CloseHandle (long hObject);
}
22/07/2011
Marcio Silveira
Qual a mensagem de erro?
Pensei numa coisa aqui, mas não faz muito sentido, porque quem interage com o hardware é o COM+, mas existem algumas configurações de segurança na framework que podem estar com baixo nível de confiança para o DotNet.
Mas faz o seguinte, tenta fazer um try/catch para pegar a InnerException. Assim talvez possamos ajudar mais.
22/07/2011
Ronaldo
Clique aqui para fazer login e interagir na Comunidade :)