use Win32::OLE; use Win32::OLE::Variant qw(:DEFAULT nothing); use Data::Dumper; my $filename = $ARGV[0]; Win32::OLE->Option( Warn => 3 ); my $open_raw_file = eval{ Win32::OLE->new('MSFileReader.XRawfile.1', sub{ $_[0]->Close } ); }; # eval if($@){ warn "Could not create XRawfile object.$@\nThis function requires Thermo MSFileReader\n"; } # if $open_raw_file->Open($filename); $open_raw_file->SetCurrentController( 0, 1 ); # mass spec device, first MS device my $scan_num = 1001; # arbitrary scan number my $arr = Variant( VT_VARIANT | VT_BYREF); my $array_size = Win32::OLE::Variant->new(VT_I4|VT_BYREF, 20); $open_raw_file->GetPrecursorInfoFromScanNum($scan_num, $arr, $array_size); my @values = @{$arr->Value}; print Dumper \@values; print "Array size is $array_size\n"; exit; Output: $VAR1 = [ '414.005279541016', '1.83302424514875e-307', '3.50253979763967e-310', '1.36817960845299e-312', '2.68156223007842e+154', '9.96719496044929e-206', '-7.16479736258273e+154', '1.1404242820188e+279', '414.005218505859', '1.20129076821422e-302', '1.74092514125002e-309', '6.80048883300789e-312', '2.65644095020843e-314', '-4.09173827895217e+149', '4.97033753286898e-290', '5.38341844184884e-309', '2.10289782884708e-311', '2.00000738352537', '7.64529567303078e-298', '2.34086864460609e-289', '5.57490734202886e-309', '4.95144931563519e+173', '5.83291545534861e-302', '4.11480344154759e-270' ]; Array size is 1 Vendor Documentation: GetPrecursorInfoFromScanNum HRESULT GetPrecursorInfoFromScanNum(long nScanNumber, VARIANT* pvarPrecursorInfos, LONG* pnArraySize) Return Value 0 if successful; otherwise, see Error Codes. Parameters nScanNumber The scan number for which the corresponding precursor info is to be returned. pvarPrecursorInfos A valid pointer to a VARIANT variable to receive the precursor info. pnArraySize A valid pointer to a long variable to receive the number of precursor info packets returned in the precursor info array. Remarks This function is used to retrieve information about the parent scans of a data dependent MSn scan. You will retrieve the scan number of the parent scan, the isolation mass used, the charge state and the monoisotopic mass as determined by the instrument firmware. You will also get access to the scan data of the parent scan in the form of a XSpectrumRead object. For the charge state and the monoisotopic mass it is tried to further refine these values from the actual parent scan data. Example struct PrecursorInfo { double dIsolationMass; double dMonoIsoMass; long nChargeState; long nScanNumber; }; void CTestOCXDlg::OnOpenParentScansOcx() { try { VARIANT vPrecursorInfos; VariantInit(&vPrecursorInfos); long nPrecursorInfos = 0; // Get the precursor scan information 2 Function Reference GetPrecursorInfoFromScanNum Thermo Scientific MSFileReader User Guide (XRawfile2.dll) 197 m_Rawfile.GetPrecursorInfoFromScanNum(m_nScanNumber, &vPrecursorInfos, &nPrecursorInfos); // Access the safearray buffer BYTE* pData; SafeArrayAccessData(vPrecursorInfos.parray, (void**)&pData); for (int i=0; i < nPrecursorInfos; ++i) { // Copy the scan information from the safearray buffer PrecursorInfo info; memcpy(&info, pData + i * sizeof(MS_PrecursorInfo), sizeof(PrecursorInfo)); // Process the paraent scan information ... } SafeArrayUnaccessData(vPrecursorInfos.parray); } catch (...) { AfxMessageBox(_T("There was a problem while getting the parent scan information.")); }