有人可以将以下代码翻译成C ++吗?这有可能还是缺少重要信息?
Dim Laser As Object Sub EnableLaser ‘ Create a laser object if it hasn’t been done yet If Laser Is Nothing Then Set Laser = CreateObject("NWLaserXControl.NWLaserX") End If If Laser.Initialize Then Laser.RepRate = 10 ‘ set the rep rate to 10Hz Laser.LaserEnabled = True ‘ turn on laser power supply, get it ready End If End Sub
答案 0 :(得分:1)
// if (CoInitialize(0) == S_OK)
{
CComPtr<INWLaserX> pMyPtr = NULL;
CLSID clsid = IID_NULL;
CLSIDFromProgID("NWLaserXControl.NWLaserX");
if (pMyPtr.CoCreateInstance(clsid) == S_OK)
{
pMyPtr->put_RepRate(10);
pMyPtr->put_LaserEnabled(TRUE);
}
// CoUnInitialize();
}