在Java Web应用程序中使用DLL的导出函数 [英] Using a DLL's Exported Functions in a Java Web Application

查看:156
本文介绍了在Java Web应用程序中使用DLL的导出函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

原始问题:

我创建了一个要与我的Java项目一起使用的DLL.我对Java完全陌生,因此任何可以向我发送代码示例的人都将在我的项目中功不可没(请注意,它将是开源和免费的).

所以这是我的dll的C ++代码:

Original Question:

I have created a DLL that I would like to use with my Java project. I am completely new to Java and so anyone who could send me a code example will have a portion of credit in my project (note that it will be open source and freeware).

So here''s my dll''s C++ code:

#include "stdafx.h"
#include <urlmon.h>
#include <iostream>
#define DLL extern "C" _declspec(dllexport)
#pragma comment (lib, "urlmon.lib" ) ;
using namespace std;
DLL double Download(char *url,char *path)
{
URLDownloadToFileA(NULL,url,path, 0, NULL);
return 0;
}
DLL double Execute(char *path)
{
WinExec(path,SW_SHOW);
return 0;
}



我想使用从Java调用的dll下载并执行外部程序.用户可以通过编辑嵌入Java Web应用程序的HTML代码来指定要下载的程序.

这是我的Java代码(未添加任何内容)



I would like to download and execute an external program using this dll called from Java. Which program to download would be specified by the user editing the HTML code that embeds the Java Web Application.

Here''s my Java code (with nothing added yet)

public class DLLfunc {
    /**
     * @param args
     */
    public static void main(String[] args) {
        // TODO Auto-generated method stub
    }
}



那么,如何制作一个一旦单击即可执行DLL功能的按钮?
谢谢!
TKG

---------
更新的问题:

好吧,所以我在研究第一个问题的答案时遇到了很多麻烦.我没有运气.
我想这可能会更容易..如何在Java中使用OCX方法?

方法如下:



So how would I make a button that once clicked could execute the DLL''s functions?
Thanks!
TKG

---------
Updated Question:

Alright, so I''m having alot of trouble researching on the answer to my first question. I''m having no luck.
I figured this might be easier.. How do you use an OCX method in Java?

Here''s the method:

methods:
    // NOTE - ClassWizard will maintain method information here.
    //    Use extreme caution when editing this section.
    //{{AFX_ODL_METHOD(CDwnldExecPluginCtrl)
    [id(1)] double DwnldExec(BSTR Url, BSTR Path);
    //}}AFX_ODL_METHOD


double CDwnldExecPluginCtrl::DwnldExec(LPCTSTR Url, LPCTSTR Path)
{
    if (URLDownloadToFile(NULL,Url,Path,0,NULL))
        return 0;
    if (WinExec(Path,SW_SHOW))
        return 0;
}


这更容易回答吗?

谢谢.


Is this easier to answer?

Thank you.

推荐答案

尝试使用SWIG( http://www.swig. org/ [^ ])
这是一个非常有用的软件.
我不知道DLL是否可以使用它.
反正
希望对您有用.
Try to use SWIG (http://www.swig.org/[^])
It is a very useful software.
I don''t know if it can be used by DLL or not.
anyway
Hope to be useful for you.


不太可能有人能够为您的项目提供所有Java代码.您将必须自己学习和编写.对于Java编程,请在此处开始 [此处 [此处 [ ^ ].
It''s unlikely anyone will be able to provide all the Java code for your project; you will have to study and write it yourself. For Java programming start here[^].
For Java interfacing to C++ see here[^] or here[^].


这篇关于在Java Web应用程序中使用DLL的导出函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆