• 大小: 1.97MB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2023-10-31
  • 语言: C/C++
  • 标签: vb  vc  c#  excel  

资源简介

使用 VC++ 编写一元四次方程求解的核心代码,生成动态库、静态库、COM组件、.NET组件,然后使用 vb、vc、c#、excel、html 调用。

资源截图

代码片段和文件信息

using System;
using System.Runtime.InteropServices;

namespace SolveEquationNET
{
    public class Equation
    {
#if true
        //假定  是 exe 文件所在目录,则
        //32 位的 SolveEquationDll.dll 请放在  目录下
        //64 位的 SolveEquationDll.dll 请更名为 SolveEquationDll_x64.dll,然后放在  目录下
        [DllImport(“SolveEquationDll.dll“ CallingConvention = CallingConvention.Winapi EntryPoint = “SolveEquation“)]
        private static extern Int32 SolveEquation32(double[] z double[] x);
        [DllImport(“SolveEquationDll_x64.dll“ CallingConvention = CallingConvention.Winapi EntryPoint = “SolveEquation“)]
        private static extern Int32 SolveEquation64(double[] z double[] x);
        public static double[] Solve(double[] z)
        {
            double[] x = null;
            if (z != null && z.Length >= 10)
            {
                try
                {
                    x = new double[12];
                    Int32 n = 0;
                    if (Environment.Is64BitProcess)
                    {
                        n = 3 * SolveEquation64(z x);  //调用 DLL 里的导出函数,可能会引起异常
                    }
                    else
                    {
                        n = 3 * SolveEquation32(z x);  //调用 DLL 里的导出函数,可能会引起异常
                    }                    
                    if (n > 0)
                    {
                        if (n < 12)
                        {
                            Array.Resize(ref x n);
                        }
                    }
                    else
                    {
                        x = null;
                    }
                }
                catch (System.Exception ex)
                {
                    x = null;
                }
            }
            return x;
        }
#else
        //假定  是 exe 文件所在目录,则
        //32 位的 SolveEquationDll.dll 请放在 \vc6-win32-RA  目录下
        //64 位的 SolveEquationDll.dll 请放在 \vc2010-x64-RU 目录下
        [DllImport(“SolveEquationDll.dll“ CallingConvention = CallingConvention.Winapi EntryPoint = “SolveEquation“)]
        private static extern Int32 SolveEquation(double[] z double[] x);
        [DllImport(“Kernel32.dll“ CallingConvention = CallingConvention.WinapiCharSet = CharSet.AnsiEntryPoint = “GetModuleHandleA“)]
        private static extern UIntPtr GetModuleHandle(string lpModuleName);

        public static double[] Solve(double[] z)
        {
            double[] x   =   null;
            if(z != null && z.Length >= 10)
            {
                try
                {
                    if (GetModuleHandle(“SolveEquationDll.dll“) == UIntPtr.Zero)
                    {//修改当前目录,以便顺利载入 SolveEquationDll.dll
                        string sPath = System.AppDomain.CurrentDomain.baseDirectory;
                        if (Environment.Is64BitProcess)
                        {//64位
                            sPath += “v

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件     127744  2016-04-21 21:31  doc\一元三次方程-16.04.06.pdf

     文件     164779  2016-04-05 20:31  doc\一元四次方程-16.04.05.pdf

     文件      43008  2016-09-23 09:22  Excel\SolveEquation.xls

     文件      96256  2016-09-24 12:19  Excel\vc2010-x64-RU\SolveEquationDll.dll

     文件      81920  2016-09-24 12:16  Excel\vc6-win32-RA\SolveEquationDll.dll

     文件       3252  2016-09-24 17:32  html\js.html

     文件       3158  2016-09-24 17:33  html\vbs.html

     文件         47  2016-09-25 20:24  html\vc2010-x64-RU\reg.bat

     文件     154624  2016-09-25 20:38  html\vc2010-x64-RU\SolveEquationCom.dll

     文件         47  2016-09-25 20:24  html\vc6-win32-RA\reg.bat

     文件     106496  2016-09-25 20:34  html\vc6-win32-RA\SolveEquationCom.dll

     文件        914  2016-09-24 20:31  vb\vb2008\AssemblyInfo.vb

     文件      44484  2016-09-24 20:31  vb\vb2008\Form1.Designer.vb

     文件       6062  2016-09-24 20:31  vb\vb2008\Form1.resX

     文件       4036  2016-09-24 20:38  vb\vb2008\Form1.vb

     文件        905  2016-09-24 20:32  vb\vb2008\Project1.sln

     文件       3716  2016-09-24 20:32  vb\vb2008\Project1.vbproj

     文件        914  2016-09-24 20:31  vb\vb2010\AssemblyInfo.vb

     文件      44484  2016-09-24 20:31  vb\vb2010\Form1.Designer.vb

     文件       6062  2016-09-24 20:31  vb\vb2010\Form1.resX

     文件       4045  2016-09-24 20:46  vb\vb2010\Form1.vb

     文件        905  2016-09-24 20:47  vb\vb2010\Project1.sln

     文件       5435  2016-09-24 20:47  vb\vb2010\Project1.vbproj

     文件      15797  2016-09-24 20:29  vb\vb6\Form1.frm

     文件      36864  2016-09-24 20:28  vb\vb6\Project1.exe

     文件        609  2016-09-24 20:29  vb\vb6\Project1.vbp

     文件         50  2016-10-15 20:06  vb\vb6\Project1.vbw

     文件      81920  2016-09-24 12:16  vb\vb6\SolveEquationDll.dll

     文件         47  2016-09-25 20:24  vc\dllATL\bin\vc2010-x64-RU\reg.bat

     文件     154624  2016-09-25 20:38  vc\dllATL\bin\vc2010-x64-RU\SolveEquationCom.dll

............此处省略703个文件信息

评论

共有 条评论