在VS2010中将C#代码转换为C ++ / cli代码

时间:2019-01-26 10:35:39

标签: c# c++-cli

我使用Windows 7和VS2010。我有一个C ++ / cli程序可以进行一些音频测量,并且效果很好。

现在在程序中我想添加一个函数,但只有C#代码。

我想将这段C#代码更改为C ++ / CLI,以便将其插入我的C ++ / CLI程序中。

C#代码:

    //C#code:
ATc.LevelAndGain.Generator.On =  true;
Thread.Sleep(1000);
    IDynamicResultGraph^ graphResult = 
ATc.LevelAndGain.Graphs[resultName].Result;
    IMeterGraph GraphResult = graphResult.AsMeterGraph();
    ATc.ThdN.Generator.On = false;

C ++ / CLI程序:

#include "stdafx.h"
using namespace System;
using namespace System::IO;
using namespace ATCAPI;
using namespace System;
using namespace System::Windows;
using namespace System::Windows::Forms;
using namespace System::Drawing;
using namespace System::Drawing::Imaging;

int main(array<System::String ^> ^args)
    {   
    //Intialize ATC
    ATC^ ATc = gcnew ATC(false);
    //Make the application visible
    ATc ->Visible = true;
    String^ fileName = "AP_result_mic.doc";
    StreamWriter^ sw = gcnew StreamWriter(fileName);    

    //figure out where the application is running, because the sample 
   project will be copied to this directory
   String^ location = System::Reflection::Assembly::GetExecutingAssembly()- 
   >Location;
   String^ directory = System::IO::Path::GetDirectoryName(location);
   //tell ATc to load the project file
   ATc ->OpenProject(System::IO::Path::Combine(directory, "SPT.abprojx"));
   ATc ->ActiveMeasurement;
   String^ signalPathName = "MIC";
   String^ measurementName = "Level and Gain";
   String^ resultName = "Level";
   //tell ATc to show the specified measurement 
   ATc ->ShowMeasurement(signalPathName, measurementName);

   ......

0 个答案:

没有答案