⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mycomclient.cpp

📁 java的com编程包
💻 CPP
字号:
#include <jni.h>
#include "HelloCom.h"
#include <stdio.h>
#include "..\Java_COM_ATL\Java_COM_ATL.h"
#include <iostream.h>

JNIEXPORT void JNICALL Java_HelloCom_HelloCom_1function
  (JNIEnv *, jobject)
{
	 

// Copy the following from the Java_COM_ATL_i.c file
// from the Java_COM_ATL project directory
//This number may be diff. as it generated by VC++ using uuidgen.exe.

	const IID IID_IJcom = {0x665A282D,0x3ECD,0x11D5,{0xAC,0x5C,0xDF,0xF9,0xE8,0x6D,0xD6,0x2D}};
	const CLSID CLSID_Jcom = {0x665A282E,0x3ECD,0x11D5,{0xAC,0x5C,0xDF,0xF9,0xE8,0x6D,0xD6,0x2D}};

// Declare and HRESULT and a pointer to the Java_COM_ATL interface
	HRESULT			hr;
	IJcom		*IJComAtl;

	// Now we will intilize COM
	hr = CoInitialize(0);

	// Use the SUCCEEDED macro and see if we can get a pointer 
	// to the interface
	if(SUCCEEDED(hr))
	{
		hr = CoCreateInstance( CLSID_Jcom, NULL, CLSCTX_INPROC_SERVER,
						IID_IJcom, (void**) &IJComAtl);
		
		// If we succeeded then call the AddNumbers method, if it failed
		// then display an appropriate message to the user.
		if(SUCCEEDED(hr))
		{
			long ReturnValue;

			hr = IJComAtl->AddNumbers(5, 7, &ReturnValue);
			cout << "The answer for 5 + 7 is: " << ReturnValue << endl;
			hr = IJComAtl->Release();  
		}
		else
		{
			printf("CoCreateInstance Failed.");
		}
	}
	// Uninitialize COM
	CoUninitialize();

    printf("Hello Com is ok and over!\n");
    return;
}






⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -