Using JNI to connect to a COM object

Hi,
I need to write an application in Java which uses a COM object. Has anyone tried to connect to/ use the functionality of a COM object by using the JNI (Java Native Interface)?
I would highly appreciate any tips on how to go about it.
Thnks,
anila

1.create a java file which is having one native function which calls the COM function.
2.In static block put
static{
System.loadlibrary("WrapperDll");
3.Compile the java file(example sample.java)
4.Create the header file using the command
javah -jni sample
4.Create a wrapper dll in VC++.
5.After creating wrapper dll in VC++ , keep the dll in the class path.
6. Run the program
See this link http://java.sun.com/docs/books/tutorial/native1.1/index.html
Bye,
nrs

Similar Messages

  • On cleanuing up COM object when using Microsoft.Office.Interop.Excel

    When using Microsoft.Office.Interop.Excel the COM objects that are created by the code must be released using System.Runtime.InteropServices.Marshal.ReleaseComObject().
    Most of the time it's pretty clear when a new COM object is created such as:
    Excel._Application excelApp = null;
    Excel._Workbook wb = null;
    Excel._Worksheet ws = null;
    Excel.Range newRange = null;
    try
    // four COM objects are created below
    excelApp = new Excel.Application();
    wb = excelApp.Workbooks.Add();
    ws = (Excel.Worksheet)wb.Worksheets.Add();
    newRange = (Excel.Range)ws.Range["A1","A30"];
    // do these line of cod create new COM object?
    newRange.Font.Bold = true;
    newRange.Borders.Color = borderColor;
    finally
    if (excelApp != null) Marshal.ReleaseComObject(excelApp)
    if (wb != null) Marshal.ReleaseComObject(wb)
    if (ws != null) Marshal.ReleaseComObject(ws)
    if (newRange != null) Marshal.ReleaseComObject(newRange)
    In the above code I create four COM objects in the first part that need to be released when I'm finished with them. But it's not clear if the other two lines of code create a new COM object or not.  If they do then my code needs to look more
    like this:
    Excel._Application excelApp = null;
    Excel._Workbook wb = null;
    Excel._Worksheet ws = null;
    Excel.Range newRange = null;
    Excel.Font fnt = null;
    Excel.Borders bds = null;
    try
    // four COM objects are created below
    excelApp = new Excel.Application();
    wb = excelApp.Workbooks.Add();
    ws = (Excel.Worksheet)wb.Worksheets.Add();
    newRange = (Excel.Range)ws.Range["A1","A30"];
    // do these line of cod create new COM object?
    fnt = newRange.Font
    fnt.Bold = true;
    bds = new newRange.Borders;
    bds.Color = borderColor;
    finally
    if (excelApp != null) Marshal.ReleaseComObject(excelApp)
    if (wb != null) Marshal.ReleaseComObject(wb)
    if (ws != null) Marshal.ReleaseComObject(ws)
    if (newRange != null) Marshal.ReleaseComObject(newRange)
    if (fnt != null) Marshal.ReleaseComObject(fnt)
    if (bds != null) Marshal.ReleaseComObject(bds)
    How can I tell if getting a property creates a new COM object or not?

    Thank you for your replay but I do understand that the font object is a COM object.  What I'm trying to figure out is if a NEW object is created each time I access the font member of a Range object and if I need to call
    Marshal.ReleaseComObject on the font object after using it.
    Most member object of an object are a single instance and each time you access the member you simply get the pointer to that instance. For example:
    using(DataTable dt = new DataTable("Some Table Name"))
    PropertyCollection ep1 = dt.ExtendedProperties;
    PropertyCollection ep2 = dt.ExtendedProperties;
    if (Object.ReferenceEquals(ep1,ep2)) Console.WriteLine("They are the same object");
    else Console.WriteLine("They are different objects");
    The output will be: They are the same object
    On the other hand this:
    Excel._Application excelApp = new Excel.Application();
    Excel._Workbook wb = excelApp.Workbooks.Add();
    Excel._Worksheet ws = (Excel.Worksheet)wb.Worksheets.Add();
    Excel.Range newRange = (Excel.Range)ws.Range["A1","A30"];
    // do these lines of code create new COM object?
    Excel.Font ef1 = newRange.Font;
    Excel.Font ef2 = newRange.Font;
    if (Object.ReferenceEquals(ef1,ef2)) Consloe.WriteLine("They are the same object");
    else Consloe.WriteLine("They are different objects");
    The output will be: They are different objects
    It looks like each time I access the font member I get a new object.  I suspect that is not the case and what I am getting is two pointers to the same object and the reference counter is incremented by one.
    So really the question is what happens to the font member object of the Range object when the range object is released.  I assume the font member will be released along with the Range object ever if the font object has a reference count greater then
    0.
    If I am correct in my assumption then I can access the font member object as much as I need to without worrying about releasing it.
    I have been reading a lot about working with COM and the need to use Marshal.ReleaseComObject and there does seem to be a lot of disagreement and even confusion on the
    mater about when and if COM objects need to be explicitly released.

  • JVM Crash When Using JNI and COM

    I'm trying to call a DLL compiled from VB6 source code that I do not have access to. The VB6 code simply retrieves data from a DB2 database using ADO and my client code grabs that data and marshals it to my Java code. I'm attempting to achieve this using JNI and COM (without a third-party bridge). It works 75% of the time, but the other 25% of the time, the JVM crashes with the usual Hotspot crash log containing an access violation exception. However, I don't know what in my C++ code (VC++ 8) could be causing this except for passing a "wild" pointer to the code lying underneath the COM object interface. If that is the case, I don't know how I am doing that.
    The Java code that is calling my native method is running on Tomcat 5.5.25 and just to be safe, I am not allowing multiple threads to concurrently call the method in my JNI DLL (though I realize that this will kill performance). Once I can get past this problem, I'll do the COM interfacing on a worker thread in my native code so I don't screw up CoInitialize and CoUninitialize calls in the case the same thread is concurrently executing multiple calls to my native code.
    I've noticed that in most cases, the JVM crashes during my call to the pClsAccount->OpenConnection method. However, my DLL isn't what is listed on the top of the call stack, which is why I suspect the passing of a wild pointer, though I'm just taking a guess at that. Does anyone have an idea as to what's going on ?
    JNIEXPORT jobject JNICALL Java_CustomerInfo_nGetCustomerAccountInfo(JNIEnv *env, jobject customerInfo, jstring accountNumber, jstring iniFileName)
    jboolean isCopy;
    // Account info class and instance to be instantiated
    jclass accountInfoCls = NULL;
    jobject accountInfoObj = NULL;
    // The constructor ID of the accountInfoCls
    jmethodID ctorID = NULL;
    // Pointer to the interface for the ClsAccount COM object
    _clsAccount *pClsAccount = NULL;
    HRESULT hr;
    BSTR bstrIniFileName(L"");
    try
    const char *nativeAccountNumber = NULL;
    if (accountNumber != NULL)
    nativeAccountNumber = env->GetStringUTFChars(accountNumber, &isCopy);
    else
    jclass newExcCls;
    env->ExceptionDescribe();
    env->ExceptionClear();
    newExcCls = env->FindClass("java/lang/IllegalArgumentException");
    env->ThrowNew(newExcCls, "accountNumber passed in was null !");
    return NULL;
    // Initialization
    variantt varConnectionSucceeded = variantt(false);
    variantt varGetAccountInfoSucceeded = variantt(false);
    variantt varAccountNumber = variantt(nativeAccountNumber);
    bstrt bstrLastPaymentDate = bstrt();
    bstrt bstrLastErrorMessage = bstrt();
    bstrt bstrLastErrorNumber = bstrt();
    jlong jTotalDue = NULL;
    jlong jEstablishedDueDay = NULL;
    jlong jLastPaymentAmount = NULL;
    jstring jLastPaymentDate = NULL;
    jstring jLastErrorMessage = NULL;
    jstring jLastErrorNumber = NULL;
    jthrowable jException = NULL;
    const char *chLastPaymentDate = NULL;
    const char *chLastErrorMessage = NULL;
    const char *chLastErrorNumber = NULL;
    long long totalDue;
    long long lastPaymentAmount;
    long establishedDueDateDay;
    //Convert string from Java string to C string to VB string
    const char *nativeIniFileName = NULL;
    if (iniFileName != NULL)
    nativeIniFileName = env->GetStringUTFChars(iniFileName, &isCopy);
    else
    jclass newExcCls;
    env->ExceptionDescribe();
    env->ExceptionClear();
    newExcCls = env->FindClass("java/lang/IllegalArgumentException");
    env->ThrowNew(newExcCls, "iniFileName passed in was null");
    return NULL;
    bstrIniFileName = comutil::ConvertStringToBSTR(nativeIniFileName);
    CoInitialize(NULL);
    // Create an instance of the COClass with the interface over it
    hr = CoCreateInstance(__uuidof(clsAccount), NULL, CLSCTX_INPROC_SERVER, __uuidof(_clsAccount), (void **)&pClsAccount);
    if (hr == S_OK)
    varConnectionSucceeded.boolVal = pClsAccount->OpenConnection(&bstrIniFileName);
     
    if (varConnectionSucceeded.boolVal == -1)
    varGetAccountInfoSucceeded.boolVal = pClsAccount->GetAccountPaymentInformation(&(varAccountNumber.GetVARIANT()));
    env->ReleaseStringUTFChars(accountNumber, nativeAccountNumber);
    // Extract all available account information from the ClsAccount object
    if (varGetAccountInfoSucceeded.boolVal == -1)
    totalDue = pClsAccount->TotalDue.int64;
    establishedDueDateDay = pClsAccount->EstablishedDueDateDay;
    lastPaymentAmount = pClsAccount->LastPaymentAmount.int64;
    bstrLastPaymentDate = pClsAccount->LastPaymentDate;
    chLastPaymentDate = comutil::ConvertBSTRToString(bstrLastPaymentDate.GetBSTR());
    jTotalDue = (jlong)totalDue;
    jEstablishedDueDay = (jlong)establishedDueDateDay;
    jLastPaymentAmount = (jlong)lastPaymentAmount;
    jLastPaymentDate = env->NewStringUTF(chLastPaymentDate);
    delete[] chLastPaymentDate;
    pClsAccount->CloseConnection();
    // Populate error fields if any errors occur
    bstrLastErrorMessage = pClsAccount->LastErrMessage;
    chLastErrorMessage = comutil::ConvertBSTRToString(bstrLastErrorMessage.GetBSTR());
    bstrLastErrorNumber = pClsAccount->LastErrNumber;
    chLastErrorNumber = comutil::ConvertBSTRToString(bstrLastErrorNumber.GetBSTR());
    jLastErrorMessage = env->NewStringUTF(chLastErrorMessage);
    jLastErrorNumber = env->NewStringUTF(chLastErrorNumber);
    delete[] chLastErrorMessage;
    delete[] chLastErrorNumber;
    const char* clsName = "com/nuance/merchantsmutual/businessentities/CustomerAccountInfo";
    // Find the Java class and the ID of its constructor
    accountInfoCls = env->FindClass(clsName);
    ctorID = env->GetMethodID(accountInfoCls, "<init>", "(JJJLjava/lang/String;Ljava/lang/String;Ljava/lang/String;)V");
    jException = env->ExceptionOccurred();
    if (jException != NULL)
    env->ExceptionDescribe();
    env->ExceptionClear();
    //Release all resources associated with the ClsAccount instance
    pClsAccount->Release();
    //Instantiate the class with the given parameters
    accountInfoObj = env->NewObject(accountInfoCls, ctorID, jTotalDue, jEstablishedDueDay, jLastPaymentAmount, jLastPaymentDate, jLastErrorMessage, jLastErrorNumber);
    jException = env->ExceptionOccurred();
    if (jException != NULL)
    env->ExceptionDescribe();
    env->ExceptionClear();
    else if (hr == REGDB_E_CLASSNOTREG)
    cout << "COM class not registered" << endl;
    else if ( hr == CLASS_E_NOAGGREGATION)
    cout << "COM class can't be aggregated" << endl;
    else if (hr == E_NOINTERFACE)
    cout << "No interface for COM class clsAccount" << endl;
    else if (hr == E_POINTER)
    cout << "*ppv pointer was NULL !" << endl;
    else
    cout << "Error occurred while creating COM object. HR is [" << hr << "]" << endl;
    // Free the BSTR because a new one was returned with a call to comutil::ConvertStringToBSTR
    SysFreeString(bstrIniFileName);
    // Release the string when it's no longer needed. MUST call if string won't be used
    // anymore or else a memory leak will occur
    env->ReleaseStringUTFChars(iniFileName, nativeIniFileName);
    CoUninitialize();
    &#12288;
    catch (_com_error &e)
    cout << "Encountered an exception in GetCustomerAccountInfo: Error was " << e.ErrorMessage();
    pClsAccount->Release();
    catch (...)
    pClsAccount->Release();
    return accountInfoObj;
    Edited by: Cthulhu76 on Jan 5, 2010 9:18 AM

    0x49202400 JavaThread "ContainerBackgroundProcessor[StandardEngine[Catalina]]" daemon [_thread_blocked, id=5340, stack(0x49bf0000,0x49c40000)]
    0x48a7e800 JavaThread "Thread-1" [_thread_in_native, id=5976, stack(0x48f00000,0x48f50000)]
    0x48a0dc00 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=3072, stack(0x48c60000,0x48cb0000)]
    0x48a09000 JavaThread "CompilerThread0" daemon [_thread_blocked, id=4988, stack(0x48c10000,0x48c60000)]
    0x48a07c00 JavaThread "Attach Listener" daemon [_thread_blocked, id=3124, stack(0x48bc0000,0x48c10000)]
    0x48a07000 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=2572, stack(0x48b70000,0x48bc0000)]
    0x489f5c00 JavaThread "Finalizer" daemon [_thread_blocked, id=5752, stack(0x48b20000,0x48b70000)]
    0x489f4c00 JavaThread "Reference Handler" daemon [_thread_blocked, id=2596, stack(0x48ad0000,0x48b20000)]
    0x003c6000 JavaThread "main" [_thread_in_native, id=4252, stack(0x00820000,0x00870000)]
    Other Threads:
    0x489f0400 VMThread [stack: 0x48a80000,0x48ad0000] [id=5624]
    0x48a18800 WatcherThread [stack: 0x48cb0000,0x48d00000] [id=1192]
    VM state:not at safepoint (normal execution)
    VM Mutex/Monitor currently owned by a thread: None
    Heap
    def new generation total 36288K, used 12762K [0x02940000, 0x050a0000, 0x07800000)
    eden space 32256K, 34% used [0x02940000, 0x0343af58, 0x048c0000)
    from space 4032K, 37% used [0x04cb0000, 0x04e2ba28, 0x050a0000)
    to space 4032K, 0% used [0x048c0000, 0x048c0000, 0x04cb0000)
    tenured generation total 483968K, used 7518K [0x07800000, 0x250a0000, 0x42940000)
    the space 483968K, 1% used [0x07800000, 0x07f57958, 0x07f57a00, 0x250a0000)
    compacting perm gen total 14080K, used 14016K [0x42940000, 0x43700000, 0x46940000)
    the space 14080K, 99% used [0x42940000, 0x436f0320, 0x436f0400, 0x43700000)
    No shared spaces configured.
    Dynamic libraries:
    0x00400000 - 0x0040f000      C:\Program Files\Apache Software Foundation\Tomcat 5.5\bin\tomcat5.exe
    0x7c800000 - 0x7c8c0000      C:\WINDOWS\system32\ntdll.dll
    0x77e40000 - 0x77f42000      C:\WINDOWS\system32\kernel32.dll
    0x77380000 - 0x77411000      C:\WINDOWS\system32\USER32.dll
    0x77c00000 - 0x77c48000      C:\WINDOWS\system32\GDI32.dll
    0x77f50000 - 0x77feb000      C:\WINDOWS\system32\ADVAPI32.dll
    0x77c50000 - 0x77cef000      C:\WINDOWS\system32\RPCRT4.dll
    0x76f50000 - 0x76f63000      C:\WINDOWS\system32\Secur32.dll
    0x77ba0000 - 0x77bfa000      C:\WINDOWS\system32\MSVCRT.dll
    0x7c8d0000 - 0x7d0cf000      C:\WINDOWS\system32\SHELL32.dll
    0x77da0000 - 0x77df2000      C:\WINDOWS\system32\SHLWAPI.dll
    0x76290000 - 0x762ad000      C:\WINDOWS\system32\IMM32.DLL
    0x77420000 - 0x77523000      C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.3790.3959_x-ww_D8713E55\comctl32.dll
    0x6d7c0000 - 0x6da10000      C:\Program Files\Java\jre1.6.0_07\bin\client\jvm.dll
    0x76aa0000 - 0x76acd000      C:\WINDOWS\system32\WINMM.dll
    0x7c340000 - 0x7c396000      C:\WINDOWS\system32\MSVCR71.dll
    0x6d270000 - 0x6d278000      C:\Program Files\Java\jre1.6.0_07\bin\hpi.dll
    0x76b70000 - 0x76b7b000      C:\WINDOWS\system32\PSAPI.DLL
    0x6d770000 - 0x6d77c000      C:\Program Files\Java\jre1.6.0_07\bin\verify.dll
    0x6d310000 - 0x6d32f000      C:\Program Files\Java\jre1.6.0_07\bin\java.dll
    0x6d7b0000 - 0x6d7bf000      C:\Program Files\Java\jre1.6.0_07\bin\zip.dll
    0x6d570000 - 0x6d583000      C:\Program Files\Java\jre1.6.0_07\bin\net.dll
    0x71c00000 - 0x71c17000      C:\WINDOWS\system32\WS2_32.dll
    0x71bf0000 - 0x71bf8000      C:\WINDOWS\system32\WS2HELP.dll
    0x71b20000 - 0x71b61000      C:\WINDOWS\system32\mswsock.dll
    0x5f270000 - 0x5f2ca000      C:\WINDOWS\system32\hnetcfg.dll
    0x71ae0000 - 0x71ae8000      C:\WINDOWS\System32\wshtcpip.dll
    0x76ed0000 - 0x76efa000      C:\WINDOWS\system32\DNSAPI.dll
    0x76f70000 - 0x76f77000      C:\WINDOWS\System32\winrnr.dll
    0x76f10000 - 0x76f3e000      C:\WINDOWS\system32\WLDAP32.dll
    0x76f80000 - 0x76f85000      C:\WINDOWS\system32\rasadhlp.dll
    0x4a6a0000 - 0x4a6ac000      C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\MMI\WEB-INF\lib\CustomerInfoProxy.dll
    0x77670000 - 0x777a9000      C:\WINDOWS\system32\ole32.dll
    0x77d00000 - 0x77d8b000      C:\WINDOWS\system32\OLEAUT32.dll
    0x7c420000 - 0x7c4a7000      C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.4053_x-ww_E6967989\MSVCP80.dll
    0x78130000 - 0x781cb000      C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.4053_x-ww_E6967989\MSVCR80.dll
    0x777b0000 - 0x77833000      C:\WINDOWS\system32\CLBCatQ.DLL
    0x77010000 - 0x770d6000      C:\WINDOWS\system32\COMRes.dll
    0x77b90000 - 0x77b98000      C:\WINDOWS\system32\VERSION.dll
    0x75da0000 - 0x75e5d000      C:\WINDOWS\system32\SXS.DLL
    0x75e60000 - 0x75e87000      C:\WINDOWS\system32\apphelp.dll
    0x4dc30000 - 0x4dc5e000      C:\WINDOWS\system32\msctfime.ime
    0x4b0d0000 - 0x4b395000      C:\WINDOWS\system32\xpsp2res.dll
    0x71bb0000 - 0x71bb9000      C:\WINDOWS\system32\WSOCK32.dll
    0x4bbe0000 - 0x4bbea000      C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\MMI\WEB-INF\lib\ClearTranProxy.dll
    0x745e0000 - 0x7489e000      C:\WINDOWS\system32\msi.dll
    0x71c40000 - 0x71c97000      C:\WINDOWS\system32\NETAPI32.dll
    0x4bc50000 - 0x4bc6c000      C:\WINDOWS\system32\DBNETLIB.DLL
    0x71f60000 - 0x71f64000      C:\WINDOWS\system32\security.dll
    0x76c90000 - 0x76cb7000      C:\WINDOWS\system32\msv1_0.dll
    0x76cf0000 - 0x76d0a000      C:\WINDOWS\system32\iphlpapi.dll
    0x761b0000 - 0x76243000      C:\WINDOWS\system32\crypt32.dll
    0x76190000 - 0x761a2000      C:\WINDOWS\system32\MSASN1.dll
    0x4bcf0000 - 0x4bcff000      C:\Program Files\Common Files\System\Ole DB\SQLOLEDB.RLL
    0x4a8a0000 - 0x4a8aa000      C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\MMI\WEB-INF\lib\MIGI.DLL
    0x73570000 - 0x736c2000      C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\MMI\WEB-INF\lib\MSVBVM60.DLL
    0x4a950000 - 0x4a9e2000      C:\Program Files\Common Files\System\ado\msado15.dll
    0x74a50000 - 0x74a6a000      C:\WINDOWS\system32\MSDART.DLL
    0x4c850000 - 0x4c8c9000      C:\Program Files\Common Files\System\Ole DB\oledb32.dll
    0x4dbb0000 - 0x4dbc1000      C:\Program Files\Common Files\System\Ole DB\OLEDB32R.DLL
    VM Arguments:
    jvm_args: -Dcatalina.home=C:\Program Files\Apache Software Foundation\Tomcat 5.5 -Dcatalina.base=C:\Program Files\Apache Software Foundation\Tomcat 5.5 -Djava.endorsed.dirs=C:\Program Files\Apache Software Foundation\Tomcat 5.5\common\endorsed -Djava.io.tmpdir=C:\Program Files\Apache Software Foundation\Tomcat 5.5\temp -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.util.logging.config.file=C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\logging.properties -Djava.library.path=C:\Program Files\Apache Software Foundation\Tomcat 5.5\webapps\MMI\WEB-INF\lib vfprintf -Xms512m -Xmx1024m
    java_command: <unknown>
    Launcher Type: generic
    Environment Variables:
    JAVA_HOME=C:\Program Files\Java\jdk1.6.0_07
    [error occurred during error reporting (printing environment variables), id 0xc0000005]
    --------------- S Y S T E M ---------------
    OS: Windows Server 2003 family Build 3790 Service Pack 2
    CPU:total 4 (4 cores per cpu, 1 threads per core) family 6 model 7 stepping 6, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3
    Memory: 4k page, physical 2097151k(2097151k free), swap 4194303k(4194303k free)
    vm_info: Java HotSpot(TM) Client VM (10.0-b23) for windows-x86 JRE (1.6.0_07-b06), built on Jun 10 2008 01:14:11 by "java_re" with MS VC++ 7.1
    time: Mon Dec 28 15:24:00 2009
    elapsed time: 600 seconds

  • #include "%(Filename)_i.h" inserted into C++ source after adding connection points to ATL object using wizard.

    What is the subsitution for this appearant macro?  Solution will not build if removed.
    Using
    Adding Connection Points to an Object directions.

    Hi Shawn,
    Since you have posted this issue to the VC++ forum, I think you would get better support there:
    http://social.msdn.microsoft.com/Forums/vstudio/en-US/8494410e-9578-4b67-a08d-3380aac10fcf/include-filenameih-inserted-into-c-source-after-adding-connection-points-to-atl-object?forum=vcgeneral#503cbc06-40a2-4073-a56e-1b384b11b56e
    So I will move this thread to the Off-topic forum. Thanks for your understanding.
    Sincerely,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Calling COM DLLs using JNI

    I am able to call ordinary dlls from my java application using JNI, by exporting the function from my DLL.
    What can I do to call COM DLLs using JNI which do not expose the
    Functions directly.
    please help!
    thanx,
    -sachin

    Is this a COM dll that you have written or do you merely have the dll?
    If you merely have the dll, there are some third party tools that will generate Java interfaces to COM objects from the dll.
    Although I don't endorse these products or work for them I've used them before with some success:
    o J-Integra -- http://www.intrinsyc.com/
    o jacoZoom -- http://www.infozoom.de/
    -- rob

  • Connecting to COM objects

    Hi everyone,
    I've got a project on the horizon that involves using an API to access a database. The API uses COM objects. 
    Can I connect to the API using <cfobject> like this:
    <cfobject 
        class = "program ID"
        name = "myneatobject"
        action = "connect"
        context = "remote"
        server = "http://someserverip">
        type = "com">
    If the server is remote, isn't there some security involved? Login credinentials?  I'm trying to ge my head around this.  There's an exisiting website in place using the API, however we're planning on redoing everything in CF. 
    Thanks for any tips in to set me straight!

    Thanks Guys.
    To be sure I'm describing this properly, I've got the manual for the API (updated in 2009) and it states
    "The  API is a COM+ application (formerly MTS). It
    provides a set of COM objects that can be manipulated by COM-
    compliant development tools such as Visual Basic, Visual C++, Visual
    C#, VSTA and so on.
    The API provides the ability to search and locate accounts across
    multiple  databases. It uses an advanced data cache mechanism to
    minimize round-trips to database servers.
    Once the account is located using a 10-digit telephone, and
    optionally an account number, each subsequent attempt to connect to an
    database requires a company number as well as a valid account
    number."
    The following example shows how to modify an existing user profile information:
    Dim objUserProfile as Object
    Dim lRetCode as Integer
    Set objUserProfile = CreateObject("EnergyAPI.cUserProfile")
    lRetCode = objUserProfile.ModifyUserInfo (sEmailAddress,
    sPassword,sName,sPAsswordHint,sHintAnswer,lPreferences,cSysUser)
    If lRetCode <> 0 Then
      ‘ Failure - Display error message
      Else
        ‘ Success
      End If
    COM+ much different than COM?? Not from what I'm reading.

  • Using COM object library & components in Java

    I've built an application that allows a PC (connected to a mobile phone by cable) to send & receive SMS from another mobile phones, using VB & Nokia PC Connectivity SDK. I want to rewrite the application in Java.
    As I have read in the documentation, Nokia PC Connectivity libraries are implemented as COM libraries. That is why I am asking if can I use COM object libraries & components in Java???
    And does Java environment supports object libraries as VB or C++ does???
    I am a VB programmer, but I am migrating now to Java which is why I have little knowledge about it. Please be kind enough to help me with this & with my learning about Java. Any help & suggestions are very well accepted.
    Thanks a lot

    I suggest that if you have a COM library dependency and lock-in, then Java is not the natural choice of platform. If you can re-write the Nokia connectivity app in Java, then that would be best. If you are just doing this to learn Java, then leave it and learn Java on a diff project!
    When you talk of object libraries, I am guessing you are just talking about software components (as COM objects could be classed)... in which case - of course Java supports components. Take a look at JavaBeans.
    HTH

  • Hi there, I am trying to connect to my server at work from home using a vpn connection. It connects fine and the time ticks along, but when i click go - connect to server, it comes up with connection failed. Please help!

    Hi there, I am trying to connect to my server at work from home using a vpn connection. It connects fine and the time ticks along, but when i click go - connect to server, it comes up with connection failed. Please help!

    ... when i click go - connect to server, it comes up with connection failed.
    If you're trying to connect to a Bonjour server on the remote network, that won't work over a layer 3 VPN. Use something like Hamachi or one of the SSH-tunnelling Bonjour proxy apps for that.

  • How can I use a COM object that does not have a type library?

    Hello,
    I've created a com server in python for which I do not have a type library. I am able to call functions for this application in Python, TCL, I'm sure VB, etc. without the type library.
    Must I have a type library registered to use this COM object with Labview? I was hoping I could simply supply the name to the refnum (or the GUID) then call functions by passings strings to the invoke node. This does not seem to be possible - am I missing something?
    In the event that I cannot use a com server without a type library. Any recommendataions on how to create one? I'm wondering if I can use the same GUID and create a shell in LabWindows which generates the IDL/TBD file I need for Labview to see my
    com server.
    Any help is greatly appreciated.
    73,
    Timothy

    Timothy Toroni wrote:
    > Thanks for the info, however their example is labview server and
    > python client. I'm going the other way. It's good to know about
    > LabPython though...
    >
    > As of now, it seems to be there is no way to use a COM object without
    > a type library from inside LabView.
    Yes that is true. LabVIEW needs that to configure the Property and
    Methode Nodes correctly. Otherwise it would need to have a special
    Property and Method Node with a configuration dialog similar to the Call
    Library Node, but a LOT more complicated. Not sure many people could
    make use of that, and it would be a very tiring experience trying to get
    things setup in that way, by going through the edit, test, and crash
    cycle over and over again.
    Rolf Kalberm
    atter
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • HT2188 i just upgraded my iphone 3gs to ios 6 not sure if it updated but now when i turn on my phone it says automatically that i need to connect it to itunes using the USB port but when i connect it it comes up as new hardware and cannot find a program/s

    i just upgraded my iphone 3gs to ios 6 not sure if it updated but now when i turn on my phone it says automatically that i need to connect it to itunes using the USB port but when i connect it it comes up as new hardware and cannot find a program/software for my device even though i have the latest itunes on my computer. i have tried reinstalling itunes but it still cannot find my phone and now i cannot use my phone as it is stuck on the sync to itunes screen

    Have you downloaded and installed the latest version of iTunes from here:
    http://www.apple.com/itunes/download/

  • Can I use UI-API connected company with DI-API business objects?

    Hi.
    I have to make some inventory transactions, by using DI-API business object Documents:
    SAPbobsCOM.Documents vInventoryGenEntry;
    vInventoryGenEntry = (SAPbobsCOM.Documents)
    oCompany.GetBusinessObject(BoObjectTypes.oInventoryGenEntry);
    But, the Company object available on UI-API doesn't give me GetBusinessObject, that is necessary to use a business object.
    Then, I think it's necessary to make at least 2 connections:
    - DI-API connection, using SAPbobsCOM.Company()
    - UI-API connection, using SboGuiApi.Connect(sConnectionString)
    Is it true?
    I'm looking for a solution that uses just one connection.
    Is there another way to do that?
    Thanks.

    Hi!
    There is a way to get a "real" company object from the ui application object, using a method called "Single sign-on". Look for it in the documentation, that is just what you need.
    Hope it helps!
                        Jon Arranz

  • COM object that has been seperated from its uderlying RCW cannot be used

    What exactly does this error mean?
    I receive this error when I perform "Unload All Modules" from the sequence editor using TestStand 4.2.1.83 development system, which is part of NI Developer Suite 2010 DS1.
    It causes TestStand to crash citing that error, and then a secondary error cites corrupted memory.

    ATE_Dude_22 wrote:
    Here is a capture of my sequence editor, where I have a alert from TestStand telling me the parameter specified doesn't match the sequence parameters (specified in the vi prototype as a string not a number), but this version of TestStand allows it to execute without needing to clear the error.
    Do you think this may have anything to do with the error I am seeing?
    Probably not. Sequence calls support mismatched parameters, what happens is that the callee gets whatever is passed to it, if that's not what it's expecting, then you might get a type mismatch error if type checking is enabled, if not then it's up to the sequence what it tries to do with the parameter for what happens next.
    Most likely the bug is in one of the code modules you are calling, probably a vi or dll is not properly maintaining a reference count somewhere or is corrupting memory and only indirectly causing the error. If most of your code is in labview, one thing to look out for is incorrectly specified calls to dlls from LabVIEW. If a call to a dll is incorrectly specified, either from LabVIEW or TestStand that can very easily lead to memory corruption and random errors later on in the code.
    I'd recommend trying to either debug and see where it's failing, if it's always failing in the same place. Or try to eliminate possibilities and reduce the called code to the minimum code required to reproduce the problem and then look for bugs in that code (paying special attention to the possibility of incorrectly specified dll calls and/or perhaps incorrectly maintained reference counts on COM objects).
    Another idea, to see if the problem is memory corruption caused by a vi, is to run all of your labview vis using the development environment (labview adapter setting), if so, any memory corruption would be in the labview process and not the main teststand process and should not bring down teststand.
    -Doug

  • "COM object that has been separated from its underlying RCW cannot be used.

    I am constantly getting the following error when closing my app if we viewed/printed a report.  What do I need to do to correct this error?  For the following error, I opened my app, viewed a report on the screen using the 'CrystalReportViewer', closed the report viewer window, closed my app.  When closing the app, the following error occurs.
    CR version: 11.5.3300.0
    VB.NET v2.
    System.Runtime.InteropServices.InvalidComObjectException was unhandled
      Message="COM object that has been separated from its underlying RCW cannot be used."
      Source="mscorlib"
      StackTrace:
           at System.Runtime.InteropServices.UCOMIConnectionPoint.Unadvise(Int32 dwCookie)
           at CrystalDecisions.ReportAppServer.%. {(_ISCDClientDocumentEvents_OnClosedEventHandler  u)
           at CrystalDecisions.ReportAppServer.%.remove_OnClosed(_ISCDClientDocumentEvents_OnClosedEventHandler value)
           at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.DisconnectEventRelay()
           at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.  (Boolean  \b, Boolean       )
           at CrystalDecisions.ReportAppServer.ReportClientDocumentWrapper.Dispose(Boolean bDisposeManaged)
           at System.ComponentModel.Component.Dispose()
           at CrystalDecisions.CrystalReports.Engine.ReportDocument.  (Boolean      :)
           at CrystalDecisions.CrystalReports.Engine.ReportDocument.  (Boolean      ;)
           at CrystalDecisions.CrystalReports.Engine.ReportDocument.Close()
           at CrystalDecisions.CrystalReports.Engine.ReportDocument.
        (Object      >, EventArgs      ?)

    Hello,
    First thing is to install Service Pack 6 which you can get from the download page by clicking on BusinessObjests tab above and then downloads on the left...
    When you close your viewer be sure to add/have Youreportobject.close and Youreportobject.Dispose. Adding a GC.Collect may help also.
    Thank you
    Don

  • Calling test sequence from CVI DLL that use ATL COM object does not work

    I am trying to call some DLL function writen in CVI from teststand. The CVI DLL is using ATL COM object(Written by me).
    The ATL COM object making instance of several ATL COM object inside it (including two controls that contains dialog). If I use a client writen in VC++ 6 and use the ATL COM (writen by me) works perfectly. But if I try to use it from CVI DLL it does not work any more.
    What is wrong? The client is passing an IUnknow interface to my component. Can anybody explain me what is wrong?

    It is not clear from your question as to what is specifically failing. If possible, one option would be to remove TestStand from the picture and see if the problem still occurs using a CVI EXE that invokes the CVI DLL.
    Scott Richardson - NI
    Scott Richardson
    National Instruments

  • Using the COM Object

    Hi ,
    Is it possible to use the COM object in Labwindows/CVI? If yes, please share the procedure?
    Thanks,
    Sumathi

    [Jongware],
    Thank you for the prompt reply!  Your information has been helpful.
    I'm not quite sure why what I'm wanting to do is against the EULA, unless it's because I'm doing it at a server level.
    Yes, COM is a Microsoft concept.  I do understand that InDesign uses the DOM, but I have seen code snippets where people have utilized the .tlb file from within .NET (C#, too).
    1. That sucks, but it is something I suppose I could live with.
    2. No comment.
    3. If my only objective is to create a thumbnail (whether it be INDD --> PDF --> JPG or INDD --> JPG), and if placing will achieve this, then that's ok.
    4. If InDesign server allows me to run a script that will do what I want, that'll work.
    5. No comment.
    6. I assume there's no way to try-before-you-buy InDesign Server?  I sure wish I could tinker with it before determining if it's the right solution.
    I know what I want is WAY overkill, but since we're a shop that uses Adobe products to print large graphics, our customers use Adobe, too.  I'm absolutely FLABBERGASTED that Adobe doesn't offer a way to easily convert their products.  And since what I want to do requires the use of Adobe in some way or fashion, I don't see any other alternative than to use a cannon to kill a fly.
    I spoke with "Travis" via chat after reading your post.  He states that Adobe does not offer a product that does what I want, nor does it offer a custom made graphic conversion program.
    What an absolute bummer.  I never thought converting an Adobe file to a thumbnail would be so difficult, especially after I noticed how Adobe Bridge flawlessly creates a visible thumbnail for all Adobe types, right in it's own window.
    Again, thanks for the information.  If you think of anything else, please let me know.
    Kyle

Maybe you are looking for