Using .tlb file in my project
-
Hello, everyone. I build a .tlb from my dll using "RegAsm" tool. Following is my part of code about dll.
@
public interface IMyTIBusAdapters
{
MyIAdapterResult MyI2C_Write(int adapter_num, byte addr, byte command, byte[] data);
int MyDiscover();
MyIReadblockResult MyI2C_Read(int adpater_num, byte addr, byte command, int len);
MyIReadblockResult MyI2C_Read_Generic_No_Restart(int adpater_num, byte addr, int len);
}
@
Then, I write Qt to call them like following
.pro file
@
QT += core gui axcontainergreaterThan(QT_MAJOR_VERSION, 4): QT += widgets
TARGET = IBM300WDebugTool
TEMPLATE = appSOURCES += main.cpp
mainwindow.cpp
tifortlbincsharpdll.cpp
TYPELIBS += $$system(dumpcpp output TIforTLBinCSharpDLL.tlb)
HEADERS += mainwindow.h
tifortlbincsharpdll.hFORMS += mainwindow.ui
@WORKER.cpp
@
MyTIBusAdapters *myTIbus; = new MyTIBusAdapters;
MyIAdapterResult *myTIWriteResult = new MyIAdapterResult();
int TIBusAddress = myTIbus->MyDiscover();
if(TIBusAddress == 0)
QMessageBox::about(this,"Warning...","Can't find TI device, please check and restart application. ");
myTIWriteResult = myTIbus->MyI2C_Write(TIBusAddress,(unsigned char)DeviceAddr[0],(unsigned
char)Command[0],requestData);
if(myTIWriteResult->isSuccess())
ui->textEdit->append("Write Successful.");
else
ui->textEdit->append("Write failed.");
@The problem is when I run on my computer, everything is OK.When I run on other computers, application could be open, but when I start following function, i would got unknown error, then my program is crashed.I found if I comment following program, this application also could work on different computers, I don't know what happen to this.
@
//myTIWriteResult = myTIbus->MyI2C_Write(TIBusAddress,(unsigned char)DeviceAddr[0],(unsigned
//char)Command[0],requestData);
@If I write program like follows, it still could run on other computers. but unfortunate, I need the response from follows.
@
myTIbus->MyI2C_Write(TIBusAddress,(unsigned char)DeviceAddr[0],(unsigned char)Command[0],requestData);
@Does anyone know what's wrong?? Thanks in advance.