int UnsafeNativeMethods.IOleContainer.EnumObjects(int grfFlags, out UnsafeNativeMethods.IEnumUnknown ppenum)
        {
            ppenum = null;

            Debug.Assert(_host != null, "gotta have the avalon activex host");

            object ax = _host.ActiveXInstance;

            //We support only one control, return that here
            //How does one add multiple controls to a container?
            if (ax != null
                &&
                ( ((grfFlags & NativeMethods.OLECONTF_EMBEDDINGS) != 0)
                  ||
                  ((grfFlags & NativeMethods.OLECONTF_ONLYIFRUNNING) != 0 &&
                    _host.ActiveXState == ActiveXHelper.ActiveXState.Running )) )
            {
                Object[] temp = new Object[1];
                temp[0]= ax;
                ppenum = new EnumUnknown(temp);
                return NativeMethods.S_OK;
            }

            ppenum = new EnumUnknown(null);
            return NativeMethods.S_OK;
        }
Exemplo n.º 2
0
        internal HtmlWindow(HtmlShimManager shimManager, UnsafeNativeMethods.IHTMLWindow2 win)
        {
            this.htmlWindow2 = win;
            Debug.Assert(this.NativeHtmlWindow != null, "The window object should implement IHTMLWindow2");

            this.shimManager = shimManager;
        }
Exemplo n.º 3
0
        internal HtmlElement(HtmlShimManager shimManager, UnsafeNativeMethods.IHTMLElement element)
        {
            this.htmlElement = element;
            Debug.Assert(this.NativeHtmlElement != null, "The element object should implement IHTMLElement");

            this.shimManager = shimManager;

        }
Exemplo n.º 4
0
        internal HtmlDocument(HtmlShimManager shimManager, UnsafeNativeMethods.IHTMLDocument doc)
        {
            this.htmlDocument2 = (UnsafeNativeMethods.IHTMLDocument2)doc;
            Debug.Assert(this.NativeHtmlDocument2 != null, "The document should implement IHtmlDocument2");

            this.shimManager = shimManager;

        }
 public int GetDropTarget(
     UnsafeNativeMethods.IOleDropTarget pDropTarget,
     out UnsafeNativeMethods.IOleDropTarget ppDropTarget)
 {
     // no additional drop target
     ppDropTarget = pDropTarget;
     return NativeMethods.SRESULTS.S_FALSE;
 }
Exemplo n.º 6
0
 string GetStringHelper(UnsafeNativeMethods.ArgsGetLineStringConsts which)
 {
   IntPtr ptr_const_this = ConstPointer();
   using (var sh = new StringHolder())
   {
     IntPtr ptr_string = sh.NonConstPointer();
     UnsafeNativeMethods.CArgsRhinoGetLine_GetString(ptr_const_this, which, ptr_string);
     return sh.ToString();
   }
 }
Exemplo n.º 7
0
 public static void EvtSeek(
                     EventLogHandle resultSet,
                     long position,
                     EventLogHandle bookmark,
                     int timeout,
                     UnsafeNativeMethods.EvtSeekFlags flags) {
     bool status = UnsafeNativeMethods.EvtSeek(resultSet, position, bookmark, timeout, flags);
     int win32Error = Marshal.GetLastWin32Error();
     if (!status)
         EventLogException.Throw(win32Error);
 }
Exemplo n.º 8
0
 /// <summary>
 /// Called when removing a delegate from an event, see the
 /// GroundPlane.Changed event for an example.
 /// </summary>
 /// <param name="type">
 /// The event watcher type index
 /// </param>
 /// <param name="value">
 /// Delegate to remove
 /// </param>
 public static void Remove(UnsafeNativeMethods.EventSyncDocumentSettingsChangedFlag type, EventHandler<RenderPropertyChangedEvent> value)
 {
   // Remove from the dictionary
   if (g_event_dictionary.ContainsKey(type)) g_event_dictionary[type] -= value;
   // If there are still event hooks set then bail
   if (!IsEmpty) return;
   // There are no event hooks set so call into rhcmnrdk_c to set the
   // callback hook to null.
   UnsafeNativeMethods.CRdkCmnEventWatcher_SetDocumentSettingsChangedEventCallback(null, Rhino.Runtime.HostUtils.m_rdk_ew_report);
   g_settings_changed_hook = null;
 }
Exemplo n.º 9
0
 int UnsafeNativeMethods.IOleContainer.EnumObjects(int grfFlags, out UnsafeNativeMethods.IEnumUnknown ppenum) {
     ppenum = null;
     if ((grfFlags & 1) != 0) { // 1 == OLECONTF_EMBEDDINGS
         Debug.Assert(parent != null, "gotta have it...");
         ArrayList list = new ArrayList();
         ListAXControls(list, true);
         if (list.Count > 0) {
             Object[] temp = new Object[list.Count];
             list.CopyTo(temp, 0);
             ppenum = new AxHost.EnumUnknown(temp);
             return NativeMethods.S_OK;
         }
     }
     ppenum = new AxHost.EnumUnknown(null);
     return NativeMethods.S_OK;
 }
Exemplo n.º 10
0
 /// <summary>
 /// Called when adding a delegate to a event, see the GroundPlane.Changed
 /// event for an example.
 /// </summary>
 /// <param name="type">
 /// The event watcher type index
 /// </param>
 /// <param name="value">
 /// Delegate to add
 /// </param>
 public static void Add(UnsafeNativeMethods.EventSyncDocumentSettingsChangedFlag type, EventHandler<RenderPropertyChangedEvent> value)
 {
   // If the callback hook has not been set then set it now
   if (g_settings_changed_hook == null)
   {
     // Call into rhcmnrdk_c to set the callback hook
     g_settings_changed_hook = OnSettingsChanged;
     UnsafeNativeMethods.CRdkCmnEventWatcher_SetDocumentSettingsChangedEventCallback(g_settings_changed_hook, Rhino.Runtime.HostUtils.m_rdk_ew_report);
   }
   if (!g_event_dictionary.ContainsKey(type))
     g_event_dictionary.Add(type, null);
   // Need to do this to ensure the delegate does not get added twice
   g_event_dictionary[type] -= value;
   // Add the new delegate to the event list
   g_event_dictionary[type] += value;
 }
Exemplo n.º 11
0
 internal ODBC32.RetCode BindColumn2(int columnNumber, ODBC32.SQL_C targetType, HandleRef buffer, IntPtr length, IntPtr srLen_or_Ind)
 {
     ODBC32.RetCode retcode = UnsafeNativeMethods.SQLBindCol(this, checked ((ushort)columnNumber), targetType, buffer, length, srLen_or_Ind);
     ODBC.TraceODBC(3, "SQLBindCol", retcode);
     return(retcode);
 }
Exemplo n.º 12
0
        /// <summary>
        /// Creates raw stylus data from the raw WM_POINTER properties
        /// </summary>
        /// <param name="pointerData">The current pointer info</param>
        /// <param name="tabletDevice">The current TabletDevice</param>
        /// <returns>An array of raw pointer data</returns>
        private int[] GenerateRawStylusData(PointerData pointerData, PointerTabletDevice tabletDevice)
        {
            // Since we are copying raw pointer data, we want to use every property supported by this pointer.
            // We may never access some of the unknown (unsupported by WPF) properties, but they should be there
            // for consumption by the developer.
            int pointerPropertyCount = tabletDevice.DeviceInfo.SupportedPointerProperties.Length;

            // The data is as wide as the pointer properties and is per history point
            int[] rawPointerData = new int[pointerPropertyCount * pointerData.Info.historyCount];

            int[] data = new int[0];

            // Get the raw data formatted to our supported properties
            if (UnsafeNativeMethods.GetRawPointerDeviceData(
                    pointerData.Info.pointerId,
                    pointerData.Info.historyCount,
                    (uint)pointerPropertyCount,
                    tabletDevice.DeviceInfo.SupportedPointerProperties,
                    rawPointerData))
            {
                // Get the X and Y offsets to translate device coords to the origin of the hwnd
                int originOffsetX, originOffsetY;
                GetOriginOffsetsLogical(out originOffsetX, out originOffsetY);

                int numButtons = tabletDevice.DeviceInfo.SupportedPointerProperties.Length - tabletDevice.DeviceInfo.SupportedButtonPropertyIndex;

                int rawDataPointSize = (numButtons > 0) ? pointerPropertyCount - numButtons + 1 : pointerPropertyCount;

                // Instead of a single entry for each button we use one entry for all buttons so reflect that in the raw data size
                data = new int[rawDataPointSize * pointerData.Info.historyCount];

                // Skip to the beginning of each stylus point in both the target WPF array and the pointer data array.
                // The pointer data is arranged from last point to first point in the history while WPF data is arranged
                // the reverse of this (in whole stylus points).  Therefore we need to fill backward from pointer data
                // via stylus point strides.
                for (int i = 0, j = rawPointerData.Length - pointerPropertyCount; i < data.Length; i += rawDataPointSize, j -= pointerPropertyCount)
                {
                    Array.Copy(rawPointerData, j, data, i, rawDataPointSize);

                    // Apply offsets from the origin to raw pointer data here
                    data[i + StylusPointDescription.RequiredXIndex] -= originOffsetX;
                    data[i + StylusPointDescription.RequiredYIndex] -= originOffsetY;

                    if (numButtons > 0)
                    {
                        int buttonIndex = i + rawDataPointSize - 1;

                        // The last data point probably has garbage in it, so clear it to store button info
                        data[buttonIndex] = 0;

                        // Condense any leftover button properties into a single entry
                        for (int k = tabletDevice.DeviceInfo.SupportedButtonPropertyIndex; k < pointerPropertyCount; k++)
                        {
                            int mask = rawPointerData[j + k] << (k - tabletDevice.DeviceInfo.SupportedButtonPropertyIndex);
                            data[buttonIndex] |= mask;
                        }
                    }
                }
            }

            return(data);
        }
Exemplo n.º 13
0
 internal ODBC32.RetCode NumberOfResultColumns(out short columnsAffected)
 {
     ODBC32.RetCode retcode = UnsafeNativeMethods.SQLNumResultCols(this, out columnsAffected);
     ODBC.TraceODBC(3, "SQLNumResultCols", retcode);
     return(retcode);
 }
Exemplo n.º 14
0
 private bool GetTriggerValue()
 {
     return(UnsafeNativeMethods.GetTriggerValue(_native));
 }
Exemplo n.º 15
0
 internal ODBC32.RetCode Prepare(string commandText)
 {
     ODBC32.RetCode retcode = UnsafeNativeMethods.SQLPrepareW(this, commandText, ODBC32.SQL_NTS);
     ODBC.TraceODBC(3, "SQLPrepareW", retcode);
     return(retcode);
 }
Exemplo n.º 16
0
 public static extern IntPtr GetHGlobalFromILockBytes(UnsafeNativeMethods.ILockBytes pLkbyt);
Exemplo n.º 17
0
 void UnsafeNativeMethods.IEnumUnknown.Clone(out UnsafeNativeMethods.IEnumUnknown ppenum)
 {
     ppenum = new EnumUnknown(this.arr, this.loc);
 }
Exemplo n.º 18
0
 IntPtr NonConstDocSunPointer()
 {
     return(UnsafeNativeMethods.Rdk_DocSun(m_doc.m_docId));
 }
Exemplo n.º 19
0
        /// <summary>
        /// Sets position of the Sun based on azimuth and altitude values.
        /// </summary>
        /// <param name="azimuthDegrees">The azimut sun angle in degrees.</param>
        /// <param name="altitudeDegrees">The altitude sun angle in degrees.</param>
        public void SetPosition(double azimuthDegrees, double altitudeDegrees)
        {
            IntPtr pSun = NonConstPointer();

            UnsafeNativeMethods.Rdk_Sun_SetAzimuthAltitude(pSun, azimuthDegrees, altitudeDegrees);
        }
Exemplo n.º 20
0
 public static void ShowHelp()
 {
     UnsafeNativeMethods.WinExec("HH NTHelp.CHM", NativeMethods.SW_SHOW);
 }
Exemplo n.º 21
0
 public static void MineAbout(string value)
 {
     UnsafeNativeMethods.ShellAbout(IntPtr.Zero, "扫雷", value, IntPtr.Zero);
 }
Exemplo n.º 22
0
 public static void FillRectangle(IntPtr hDC, int x, int y, int cx, int cy, int color)
 {
     UnsafeNativeMethods.SetBkColor(hDC, color);
     NativeMethods.RECT rect = new NativeMethods.RECT(x, y, x + cx, y + cy);
     UnsafeNativeMethods.ExtTextOut(hDC, 0, 0, NativeMethods.ETO_OPAQUE, ref rect, IntPtr.Zero, 0, IntPtr.Zero);
 }
Exemplo n.º 23
0
        /// <summary>
        /// Processes the latest WM_POINTER message and forwards it to the WPF input stack.
        /// </summary>
        /// <param name="pointerId">The id of the pointer message</param>
        /// <param name="action">The stylus action being done</param>
        /// <param name="timestamp">The time (in ticks) the message arrived</param>
        /// <returns>True if successfully processed (handled), false otherwise</returns>
        private bool ProcessMessage(uint pointerId, RawStylusActions action, int timestamp)
        {
            bool handled = false;

            // Acquire all pointer data needed
            PointerData data = new PointerData(pointerId);

            // Only process touch or pen messages, do not process mouse or touchpad
            if (data.IsValid &&
                (data.Info.pointerType == UnsafeNativeMethods.POINTER_INPUT_TYPE.PT_TOUCH ||
                 data.Info.pointerType == UnsafeNativeMethods.POINTER_INPUT_TYPE.PT_PEN))
            {
                uint cursorId = 0;

                if (UnsafeNativeMethods.GetPointerCursorId(pointerId, ref cursorId))
                {
                    IntPtr deviceId = data.Info.sourceDevice;

                    // If we cannot acquire the latest tablet and stylus then wait for the
                    // next message.
                    if (!UpdateCurrentTabletAndStylus(deviceId, cursorId))
                    {
                        return(false);
                    }

                    // Convert move to InAirMove if applicable
                    if (action == RawStylusActions.Move &&
                        (!data.Info.pointerFlags.HasFlag(UnsafeNativeMethods.POINTER_FLAGS.POINTER_FLAG_INCONTACT) &&
                         data.Info.pointerFlags.HasFlag(UnsafeNativeMethods.POINTER_FLAGS.POINTER_FLAG_INRANGE)))
                    {
                        action = RawStylusActions.InAirMove;
                    }

                    // Generate a raw input to send to the input manager to start the event chain in PointerLogic
                    RawStylusInputReport rsir =
                        new RawStylusInputReport(
                            InputMode.Foreground,
                            timestamp,
                            _source.Value,
                            action,
                            () => { return(_currentTabletDevice.StylusPointDescription); },
                            _currentTabletDevice.Id,
                            _currentStylusDevice.Id,
                            GenerateRawStylusData(data, _currentTabletDevice))
                    {
                        StylusDevice = _currentStylusDevice.StylusDevice,
                    };

                    // Send the input report to the stylus plugins if we're not doing a drag and the window
                    // is currently enabled.
                    if (!_pointerLogic.Value.InDragDrop && IsWindowEnabled)
                    {
                        PointerStylusPlugInManager manager;

                        if (_pointerLogic.Value.PlugInManagers.TryGetValue(_source.Value, out manager))
                        {
                            manager.InvokeStylusPluginCollection(rsir);
                        }
                    }

                    // Update the data in the stylus device with the latest pointer data
                    _currentStylusDevice.Update(this, _source.Value, data, rsir);

                    // Call the StylusDevice to process and fire any interactions that
                    // might have resulted from the input.  If the originating inputs
                    // have been handled, we don't want to generate any gestures.
                    _currentStylusDevice.UpdateInteractions(rsir);

                    InputReportEventArgs irea = new InputReportEventArgs(_currentStylusDevice.StylusDevice, rsir)
                    {
                        RoutedEvent = InputManager.PreviewInputReportEvent,
                    };

                    // Now send the input report
                    InputManager.UnsecureCurrent.ProcessInput(irea);

                    // If this is not a primary pointer input, we don't want to
                    // allow it to go to DefWindowProc, so we should handle it.
                    // This ensures that primary pointer to mouse promotions
                    // will occur in multi-touch scenarios.
                    // We don't use the results of the input processing here as doing
                    // so could possibly cause some messages of a pointer chain as
                    // being handled, and some as being unhandled.  This results in
                    // undefined behavior in the WM_POINTER stack.
                    // <see cref="https://msdn.microsoft.com/en-us/library/windows/desktop/hh454923(v=vs.85).aspx"/>
                    handled = !_currentStylusDevice.IsPrimary;
                }
            }

            return(handled);
        }
Exemplo n.º 24
0
        int UnsafeNativeMethods.IOleInPlaceSite.GetWindowContext(out UnsafeNativeMethods.IOleInPlaceFrame ppFrame, out UnsafeNativeMethods.IOleInPlaceUIWindow ppDoc,
                                             NativeMethods.COMRECT lprcPosRect, NativeMethods.COMRECT lprcClipRect, NativeMethods.OLEINPLACEFRAMEINFO lpFrameInfo)
        {
            ppDoc = null;
            ppFrame = this.Host.Container;
            
            lprcPosRect.left = (int) this.Host.Bounds.left;
            lprcPosRect.top =  (int) this.Host.Bounds.top;
            lprcPosRect.right = (int) this.Host.Bounds.right;
            lprcPosRect.bottom = (int) this.Host.Bounds.bottom;
            
            lprcClipRect = this.Host.Bounds;
            if (lpFrameInfo != null) 
            {
                lpFrameInfo.cb = (uint)Marshal.SizeOf(typeof(NativeMethods.OLEINPLACEFRAMEINFO));
                lpFrameInfo.fMDIApp = false;
                lpFrameInfo.hAccel = IntPtr.Zero;
                lpFrameInfo.cAccelEntries = 0;
                lpFrameInfo.hwndFrame = this.Host.ParentHandle.Handle;
            }

            return NativeMethods.S_OK;
        }
Exemplo n.º 25
0
 internal HtmlElementCollection(HtmlShimManager shimManager, UnsafeNativeMethods.IHTMLElementCollection elements) {
     this.htmlElementCollection = elements;
     this.elementsArray = null;
     this.shimManager = shimManager;
     Debug.Assert(this.NativeHtmlElementCollection != null, "The element collection object should implement IHTMLElementCollection");
 }
Exemplo n.º 26
0
 /// <summary>
 /// Create a non-document controlled Sun
 /// </summary>
 public Sun()
 {
     m_pLocalSun = UnsafeNativeMethods.Rdk_SunNew();
     m_doc       = null;
 }
Exemplo n.º 27
0
 public static extern UnsafeNativeMethods.IStorage StgCreateDocfileOnILockBytes(UnsafeNativeMethods.ILockBytes iLockBytes, int grfMode, int reserved);
 /// <summary>
 /// Tests for a valid model component name.
 /// </summary>
 /// <param name="name">The string to validate.</param>
 /// <returns>true if the string is a valid model component name, false otherwise.</returns>
 /// <since>6.15</since>
 public static bool IsValidComponentName(string name)
 {
     return(UnsafeNativeMethods.ON_ModelComponent_IsValidComponentName(name));
 }
Exemplo n.º 29
0
 public int ResizeBorder(
     NativeMethods.COMRECT rect,
     UnsafeNativeMethods.IOleInPlaceUIWindow doc,
     bool fFrameWindow)
 {
     // We don't have any UI by default, so pretend we updated it.
     return NativeMethods.SRESULTS.S_OK;
 }
        public uint DataCRC(uint currentRemainder)
        {
            var const_ptr = ConstPointer();

            return(UnsafeNativeMethods.ON_ModelComponent_DataCRC(const_ptr, currentRemainder));
        }
Exemplo n.º 31
0
 internal static IntPtr NarrowBase(IntPtr ptr)
 {
     return(UnsafeNativeMethods.NativeNarrowBase(ptr));
 }
Exemplo n.º 32
0
 internal State RefreshStorage(UnsafeNativeMethods.IPersistStorage iPersistStorage) {
     Debug.Assert(storage != null, "how can we not have a storage object?");
     Debug.Assert(iLockBytes != null, "how can we have a storage w/o ILockBytes?");
     if (storage == null || iLockBytes == null) return null;
     iPersistStorage.Save(storage, true);
     storage.Commit(0);
     iPersistStorage.HandsOffStorage();
     try {
         buffer = null;
         ms = null;
         NativeMethods.STATSTG stat = new NativeMethods.STATSTG();
         iLockBytes.Stat(stat, NativeMethods.Ole.STATFLAG_NONAME);
         length = (int) stat.cbSize;
         buffer = new byte[length];
         IntPtr hglobal = UnsafeNativeMethods.GetHGlobalFromILockBytes(iLockBytes);
         IntPtr pointer = UnsafeNativeMethods.GlobalLock(new HandleRef(null, hglobal));
         try {
             if (pointer != IntPtr.Zero) {
                 Marshal.Copy(pointer, buffer, 0, length);
             }
             else {
                 length = 0;
                 buffer = null;
             }
         }
         finally {
             UnsafeNativeMethods.GlobalUnlock(new HandleRef(null, hglobal));
         }
     }
     finally {
         iPersistStorage.SaveCompleted(storage);
     }
     return this;
 }
        /// <summary>
        /// Scans for all attached removable devices
        /// </summary>
        public Task <IEnumerable <InstalledMountedDriveInfo> > ScanAttachedDrivesAsync()
        {
            var installedMountedDrives = new SortedList <string, InstalledMountedDriveInfo>();

            try
            {
                var environmentDrives = new Hashtable();
                var mountedDrives     = new Hashtable();

                foreach (var drive in Environment.GetLogicalDrives())
                {
                    environmentDrives.Add(drive, new DriveInfo(drive));
                }

                var mountedDevices = Registry.LocalMachine.OpenSubKey("SYSTEM\\MountedDevices");

                if (mountedDevices?.ValueCount > 0)
                {
                    var mountedDeviceNames = mountedDevices.GetValueNames()
                                             .Where(name => name.StartsWith("\\DosDevices\\"));

                    foreach (var mountedDeviceName in mountedDeviceNames)
                    {
                        var driveLetter = new StringBuilder(mountedDeviceName.Substring(12));
                        driveLetter.Append("\\");

                        if (!environmentDrives.ContainsKey(driveLetter.ToString()))
                        {
                            continue;
                        }

                        var thisDriveInfo = (DriveInfo)environmentDrives[driveLetter.ToString()];

                        if (thisDriveInfo.DriveType != DriveType.Removable)
                        {
                            continue;
                        }

                        var bytes   = (byte[])mountedDevices.GetValue(mountedDeviceName);
                        var cleaned = new byte[bytes.Length - 1];

                        var pointer           = 0;
                        var firstSlashFound   = false;
                        var secondSlashFound  = false;
                        var questionMarkFound = false;

                        foreach (var character in (byte[])mountedDevices.GetValue(mountedDeviceName))
                        {
                            if (character == 0)
                            {
                                continue;
                            }

                            if (firstSlashFound)
                            {
                                if (questionMarkFound)
                                {
                                    if (secondSlashFound)
                                    {
                                        cleaned[pointer] = character;
                                        pointer++;
                                    }
                                    else
                                    {
                                        if (character == 92)
                                        {
                                            secondSlashFound = true;
                                        }
                                    }
                                }
                                else
                                {
                                    if (character == 63)
                                    {
                                        questionMarkFound = true;
                                    }
                                }
                            }
                            else
                            {
                                if (character == 92)
                                {
                                    firstSlashFound = true;
                                }
                            }
                        }

                        var finished = new byte[pointer];
                        for (var i = 0; i < pointer; i++)
                        {
                            finished[i] = cleaned[i];
                        }

                        mountedDrives.Add(driveLetter,
                                          new MountedDriveInfo(thisDriveInfo, Encoding.Default.GetString(finished).ToUpper()));
                    }
                }

                mountedDevices?.Close();

                var classGuid     = new Guid(UnsafeNativeMethods.GUID_DEVINTERFACE_VOLUME);
                var deviceInfoSet = UnsafeNativeMethods.SetupDiGetClassDevs(ref classGuid, 0, IntPtr.Zero,
                                                                            UnsafeNativeMethods.DIGCF_DEVICEINTERFACE | UnsafeNativeMethods.DIGCF_PRESENT);

                if (deviceInfoSet.ToInt32() == UnsafeNativeMethods.INVALID_HANDLE_VALUE)
                {
                    return(Task.FromResult(Enumerable.Empty <InstalledMountedDriveInfo>()));
                }

                var index = 0;

                while (true)
                {
                    var size = 0;

                    var interfaceData = new UnsafeNativeMethods.SP_DEVICE_INTERFACE_DATA();
                    var devData       = new UnsafeNativeMethods.SP_DEVINFO_DATA();
                    var detailData    = new UnsafeNativeMethods.SP_DEVICE_INTERFACE_DETAIL_DATA();

                    if (
                        !UnsafeNativeMethods.SetupDiEnumDeviceInterfaces(deviceInfoSet, null, ref classGuid, index,
                                                                         interfaceData))
                    {
                        break;
                    }

                    UnsafeNativeMethods.SetupDiGetDeviceInterfaceDetail(deviceInfoSet, interfaceData, IntPtr.Zero, 0,
                                                                        ref size, devData);

                    var buffer = Marshal.AllocHGlobal(size);

                    // for 64 bit system, the size needs to be 8, for 32 bit system, the size needs to be 5
                    if (IntPtr.Size == 8)
                    {
                        detailData.cbSize = 8;
                    }
                    else
                    {
                        detailData.cbSize = Marshal.SizeOf(typeof(UnsafeNativeMethods.SP_DEVICE_INTERFACE_DETAIL_DATA));
                    }

                    Marshal.StructureToPtr(detailData, buffer, false);

                    if (!UnsafeNativeMethods.SetupDiGetDeviceInterfaceDetail(deviceInfoSet, interfaceData,
                                                                             buffer, size, ref size, devData))
                    {
                        Marshal.FreeHGlobal(buffer);
                    }

                    var pDevicePath = (IntPtr)((int)buffer + Marshal.SizeOf(typeof(int)));
                    var devicePath  = Marshal.PtrToStringAuto(pDevicePath);

                    if (devicePath != null)
                    {
                        devicePath = devicePath.ToUpper();
                        Marshal.FreeHGlobal(buffer);

                        foreach (MountedDriveInfo mountedDrive in mountedDrives.Values)
                        {
                            if (!devicePath.Contains(mountedDrive.RegistryInfo))
                            {
                                continue;
                            }

                            var thisMountedDrive = new InstalledMountedDriveInfo(mountedDrive.DriveInfo,
                                                                                 devData.devInst, (UnsafeNativeMethods.DeviceCapabilities)
                                                                                 UnsafeNativeMethods.GetProperty(deviceInfoSet, devData,
                                                                                                                 UnsafeNativeMethods.SPDRP_CAPABILITIES, 0),
                                                                                 UnsafeNativeMethods.GetProperty(deviceInfoSet, devData,
                                                                                                                 UnsafeNativeMethods.SPDRP_PHYSICAL_DEVICE_OBJECT_NAME, "bad name"));

                            try
                            {
                                // Check attempts to add duplicate drives when the SetupDiEnumDeviceInterfaces call does not break
                                // on first call for a particular drive (multiple device interfaces).

                                if (installedMountedDrives.ContainsKey(thisMountedDrive.Description) == false)
                                {
                                    installedMountedDrives.Add(thisMountedDrive.Description, thisMountedDrive);
                                }
                            }
                            catch (Exception)
                            {
                                // Ignore unspecified exceptions and continue building mounted drives
                            }
                        }
                    }

                    index++;
                }
            }
            catch (Exception ex)
            {
                _logger.Log(ex);
            }

            _events.GetEvent <ScanDrivesCompletedEvent>().Publish(installedMountedDrives.Values.AsEnumerable());

            return(Task.FromResult(installedMountedDrives.Values.AsEnumerable()));
        }
Exemplo n.º 34
0
 internal ODBC32.RetCode BindColumn3(int columnNumber, ODBC32.SQL_C targetType, IntPtr srLen_or_Ind)
 {
     ODBC32.RetCode retcode = UnsafeNativeMethods.SQLBindCol(this, checked ((ushort)columnNumber), targetType, ADP.PtrZero, ADP.PtrZero, srLen_or_Ind);
     ODBC.TraceODBC(3, "SQLBindCol", retcode);
     return(retcode);
 }
Exemplo n.º 35
0
 /// <summary>
 /// Helper function to set or clear a bit in the flags field.
 /// </summary>
 /// <param name="flag">The Flag bit to set or clear.</param>
 /// <param name="value">True to set, false to clear the bit in the flags field.</param>
 private void SetFlag(UnsafeNativeMethods.TASKDIALOG_FLAGS flag, bool value)
 {
     if (value)
     {
         this.flags |= flag;
     }
     else
     {
         this.flags &= ~flag;
     }
 }
        public void WriteData(string fileName, string templateFileName, byte[] data, ref long readTime)
        {
            if (!fileName.ToLowerInvariant().EndsWith(".config", StringComparison.Ordinal))
            {
                throw new Exception(SR.GetString(SR.Can_not_access_files_other_than_config));
            }

            bool           fileExists        = File.Exists(fileName);
            FileInfo       fileInfo          = null;
            FileAttributes fileAttributes    = FileAttributes.Normal;
            string         tempFile          = null;
            Exception      createStreamExcep = null;
            FileStream     tempFileStream    = null;
            long           lastWriteTicks    = 0;
            long           utcNowTicks       = 0;

            /////////////////////////////////////////////////////////////////////
            // Step 1: If the file exists, then make sure it hasn't been written to since it was read
            if (fileExists && File.GetLastWriteTimeUtc(fileName).Ticks > readTime)
            {
                throw new Exception(SR.GetString(SR.File_changed_since_read, fileName));
            }

            /////////////////////////////////////////////////////////////////////
            // Step 2: Get the security-descriptor and attributes of the file
            if (fileExists)
            {
                try {
                    fileInfo       = new FileInfo(fileName);
                    fileAttributes = fileInfo.Attributes;
                } catch { }
                if (((int)(fileAttributes & (FileAttributes.ReadOnly | FileAttributes.Hidden))) != 0)
                {
                    throw new Exception(SR.GetString(SR.File_is_read_only, fileName));
                }
            }

            /////////////////////////////////////////////////////////////////////
            // Step 3: Generate a temp file name. Make sure that the temp file doesn't exist
            tempFile = fileName + "." + GetRandomFileExt() + ".tmp";
            for (int iter = 0; File.Exists(tempFile); iter++) // if it exists, then use a different random name
            {
                if (iter > 100)                               // don't try more than 100 times
                {
                    throw new Exception(SR.GetString(SR.Unable_to_create_temp_file));
                }
                else
                {
                    tempFile = fileName + "." + GetRandomFileExt() + ".tmp";
                }
            }

            /////////////////////////////////////////////////////////////////////
            // Step 4: Write the buffer to the temp file, and move it to the actual file
            try {
                tempFileStream = new FileStream(tempFile, FileMode.CreateNew, FileAccess.Write, FileShare.ReadWrite, data.Length, FileOptions.WriteThrough);
                tempFileStream.Write(data, 0, data.Length);
            } catch (Exception e) {
                createStreamExcep = e;
            } finally {
                if (tempFileStream != null)
                {
                    tempFileStream.Close();
                }
            }
            if (createStreamExcep != null)
            {
                try {
                    File.Delete(tempFile);
                } catch { }
                throw createStreamExcep;
            }
            if (fileExists)
            {
                try {
                    DuplicateFileAttributes(fileName, tempFile);
                } catch { }
            }
            else if (templateFileName != null)
            {
                try {
                    DuplicateTemplateAttributes(fileName, templateFileName);
                } catch { }
            }

            /////////////////////////////////////////////////////////////////////
            // Step 4: Move the temp filt to the actual file
            if (!UnsafeNativeMethods.MoveFileEx(tempFile, fileName, MOVEFILE_COPY_ALLOWED | MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH))
            {
                try {
                    File.Delete(tempFile);
                } catch { }
                Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());
            }

            /////////////////////////////////////////////////////////////////////
            // Step 5: Set the attributes of the file
            if (fileExists)
            {
                fileInfo            = new FileInfo(fileName);
                fileInfo.Attributes = fileAttributes;
            }

            /////////////////////////////////////////////////////////////////////
            // Step 6: Record the current time as the read-time
            lastWriteTicks = File.GetLastWriteTimeUtc(fileName).Ticks;
            utcNowTicks    = DateTime.UtcNow.Ticks;
            readTime       = (utcNowTicks > lastWriteTicks ? utcNowTicks : lastWriteTicks);
        }
Exemplo n.º 37
0
        private unsafe void SetSearchPreferences(UnsafeNativeMethods.IDirectorySearch adsSearch, bool findMoreThanOne)
        {
            ArrayList prefList = new ArrayList();
            AdsSearchPreferenceInfo info;

            // search scope
            info = new AdsSearchPreferenceInfo();
            info.dwSearchPref = (int)AdsSearchPreferences.SEARCH_SCOPE;
            info.vValue = new AdsValueHelper((int)SearchScope).GetStruct();
            prefList.Add(info);

            // size limit
            if (_sizeLimit != 0 || !findMoreThanOne)
            {
                info = new AdsSearchPreferenceInfo();
                info.dwSearchPref = (int)AdsSearchPreferences.SIZE_LIMIT;
                info.vValue = new AdsValueHelper(findMoreThanOne ? SizeLimit : 1).GetStruct();
                prefList.Add(info);
            }

            // time limit
            if (ServerTimeLimit >= new TimeSpan(0))
            {
                info = new AdsSearchPreferenceInfo();
                info.dwSearchPref = (int)AdsSearchPreferences.TIME_LIMIT;
                info.vValue = new AdsValueHelper((int)ServerTimeLimit.TotalSeconds).GetStruct();
                prefList.Add(info);
            }

            // propertyNamesOnly
            info = new AdsSearchPreferenceInfo();
            info.dwSearchPref = (int)AdsSearchPreferences.ATTRIBTYPES_ONLY;
            info.vValue = new AdsValueHelper(PropertyNamesOnly).GetStruct();
            prefList.Add(info);

            // Timeout
            if (ClientTimeout >= new TimeSpan(0))
            {
                info = new AdsSearchPreferenceInfo();
                info.dwSearchPref = (int)AdsSearchPreferences.TIMEOUT;
                info.vValue = new AdsValueHelper((int)ClientTimeout.TotalSeconds).GetStruct();
                prefList.Add(info);
            }

            // page size
            if (PageSize != 0)
            {
                info = new AdsSearchPreferenceInfo();
                info.dwSearchPref = (int)AdsSearchPreferences.PAGESIZE;
                info.vValue = new AdsValueHelper(PageSize).GetStruct();
                prefList.Add(info);
            }

            // page time limit
            if (ServerPageTimeLimit >= new TimeSpan(0))
            {
                info = new AdsSearchPreferenceInfo();
                info.dwSearchPref = (int)AdsSearchPreferences.PAGED_TIME_LIMIT;
                info.vValue = new AdsValueHelper((int)ServerPageTimeLimit.TotalSeconds).GetStruct();
                prefList.Add(info);
            }

            // chase referrals
            info = new AdsSearchPreferenceInfo();
            info.dwSearchPref = (int)AdsSearchPreferences.CHASE_REFERRALS;
            info.vValue = new AdsValueHelper((int)ReferralChasing).GetStruct();
            prefList.Add(info);

            // asynchronous
            if (Asynchronous == true)
            {
                info = new AdsSearchPreferenceInfo();
                info.dwSearchPref = (int)AdsSearchPreferences.ASYNCHRONOUS;
                info.vValue = new AdsValueHelper(Asynchronous).GetStruct();
                prefList.Add(info);
            }

            // tombstone
            if (Tombstone == true)
            {
                info = new AdsSearchPreferenceInfo();
                info.dwSearchPref = (int)AdsSearchPreferences.TOMBSTONE;
                info.vValue = new AdsValueHelper(Tombstone).GetStruct();
                prefList.Add(info);
            }

            // attributescopequery
            if (_attributeScopeQuerySpecified)
            {
                info = new AdsSearchPreferenceInfo();
                info.dwSearchPref = (int)AdsSearchPreferences.ATTRIBUTE_QUERY;
                info.vValue = new AdsValueHelper(AttributeScopeQuery, AdsType.ADSTYPE_CASE_IGNORE_STRING).GetStruct();
                prefList.Add(info);
            }

            // derefalias
            if (DerefAlias != DereferenceAlias.Never)
            {
                info = new AdsSearchPreferenceInfo();
                info.dwSearchPref = (int)AdsSearchPreferences.DEREF_ALIASES;
                info.vValue = new AdsValueHelper((int)DerefAlias).GetStruct();
                prefList.Add(info);
            }

            // securitymask
            if (SecurityMasks != SecurityMasks.None)
            {
                info = new AdsSearchPreferenceInfo();
                info.dwSearchPref = (int)AdsSearchPreferences.SECURITY_MASK;
                info.vValue = new AdsValueHelper((int)SecurityMasks).GetStruct();
                prefList.Add(info);
            }

            // extendeddn
            if (ExtendedDN != ExtendedDN.None)
            {
                info = new AdsSearchPreferenceInfo();
                info.dwSearchPref = (int)AdsSearchPreferences.EXTENDED_DN;
                info.vValue = new AdsValueHelper((int)ExtendedDN).GetStruct();
                prefList.Add(info);
            }

            // dirsync
            if (directorySynchronizationSpecified)
            {
                info = new AdsSearchPreferenceInfo();
                info.dwSearchPref = (int)AdsSearchPreferences.DIRSYNC;
                info.vValue = new AdsValueHelper(DirectorySynchronization.GetDirectorySynchronizationCookie(), AdsType.ADSTYPE_PROV_SPECIFIC).GetStruct();
                prefList.Add(info);

                if (DirectorySynchronization.Option != DirectorySynchronizationOptions.None)
                {
                    info = new AdsSearchPreferenceInfo();
                    info.dwSearchPref = (int)AdsSearchPreferences.DIRSYNC_FLAG;
                    info.vValue = new AdsValueHelper((int)DirectorySynchronization.Option).GetStruct();
                    prefList.Add(info);
                }
            }

            IntPtr ptrToFree = (IntPtr)0;
            IntPtr ptrVLVToFree = (IntPtr)0;
            IntPtr ptrVLVContexToFree = (IntPtr)0;

            try
            {
                // sort
                if (Sort.PropertyName != null && Sort.PropertyName.Length > 0)
                {
                    info = new AdsSearchPreferenceInfo();
                    info.dwSearchPref = (int)AdsSearchPreferences.SORT_ON;
                    AdsSortKey sortKey = new AdsSortKey();
                    sortKey.pszAttrType = Marshal.StringToCoTaskMemUni(Sort.PropertyName);
                    ptrToFree = sortKey.pszAttrType; // so we can free it later.
                    sortKey.pszReserved = (IntPtr)0;
                    sortKey.fReverseOrder = (Sort.Direction == SortDirection.Descending) ? -1 : 0;
                    byte[] sortKeyBytes = new byte[Marshal.SizeOf(sortKey)];
                    Marshal.Copy((INTPTR_INTPTRCAST)(&sortKey), sortKeyBytes, 0, sortKeyBytes.Length);
                    info.vValue = new AdsValueHelper(sortKeyBytes, AdsType.ADSTYPE_PROV_SPECIFIC).GetStruct();
                    prefList.Add(info);
                }

                // vlv
                if (directoryVirtualListViewSpecified)
                {
                    info = new AdsSearchPreferenceInfo();
                    info.dwSearchPref = (int)AdsSearchPreferences.VLV;
                    AdsVLV vlvValue = new AdsVLV();
                    vlvValue.beforeCount = _vlv.BeforeCount;
                    vlvValue.afterCount = _vlv.AfterCount;
                    vlvValue.offset = _vlv.Offset;
                    //we need to treat the empty string as null here
                    if (_vlv.Target.Length != 0)
                        vlvValue.target = Marshal.StringToCoTaskMemUni(_vlv.Target);
                    else
                        vlvValue.target = IntPtr.Zero;
                    ptrVLVToFree = vlvValue.target;
                    if (_vlv.DirectoryVirtualListViewContext == null)
                    {
                        vlvValue.contextIDlength = 0;
                        vlvValue.contextID = (IntPtr)0;
                    }
                    else
                    {
                        vlvValue.contextIDlength = _vlv.DirectoryVirtualListViewContext.context.Length;
                        vlvValue.contextID = Marshal.AllocCoTaskMem(vlvValue.contextIDlength);
                        ptrVLVContexToFree = vlvValue.contextID;
                        Marshal.Copy(_vlv.DirectoryVirtualListViewContext.context, 0, vlvValue.contextID, vlvValue.contextIDlength);
                    }
                    IntPtr vlvPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(AdsVLV)));
                    byte[] vlvBytes = new byte[Marshal.SizeOf(vlvValue)];
                    try
                    {
                        Marshal.StructureToPtr(vlvValue, vlvPtr, false);
                        Marshal.Copy(vlvPtr, vlvBytes, 0, vlvBytes.Length);
                    }
                    finally
                    {
                        Marshal.FreeHGlobal(vlvPtr);
                    }
                    info.vValue = new AdsValueHelper(vlvBytes, AdsType.ADSTYPE_PROV_SPECIFIC).GetStruct();
                    prefList.Add(info);
                }

                // cacheResults
                if (_cacheResultsSpecified)
                {
                    info = new AdsSearchPreferenceInfo();
                    info.dwSearchPref = (int)AdsSearchPreferences.CACHE_RESULTS;
                    info.vValue = new AdsValueHelper(CacheResults).GetStruct();
                    prefList.Add(info);
                }

                //
                // now make the call
                //                
                AdsSearchPreferenceInfo[] prefs = new AdsSearchPreferenceInfo[prefList.Count];
                for (int i = 0; i < prefList.Count; i++)
                {
                    prefs[i] = (AdsSearchPreferenceInfo)prefList[i];
                }

                DoSetSearchPrefs(adsSearch, prefs);
            }
            finally
            {
                if (ptrToFree != (IntPtr)0)
                    Marshal.FreeCoTaskMem(ptrToFree);

                if (ptrVLVToFree != (IntPtr)0)
                    Marshal.FreeCoTaskMem(ptrVLVToFree);

                if (ptrVLVContexToFree != (IntPtr)0)
                    Marshal.FreeCoTaskMem(ptrVLVContexToFree);
            }
        }
 void SetBool(UnsafeNativeMethods.FileWriteOptionsBoolConsts which, bool value)
 {
   if (m_bDoDelete) // means this is not "const"
     UnsafeNativeMethods.CRhinoFileWriteOptions_SetBool(m_ptr, which, value);
 }
        /// <summary>
        /// Locks the component Name property.
        /// </summary>
        /// <since>6.0</since>
        public void LockName()
        {
            IntPtr non_const_ptr = NonConstPointer();

            UnsafeNativeMethods.ON_ModelComponent_LockName(non_const_ptr);
        }
Exemplo n.º 40
0
 internal ODBC32.RetCode SetStatementAttribute(ODBC32.SQL_ATTR attribute, IntPtr value, ODBC32.SQL_IS stringLength)
 {
     ODBC32.RetCode retcode = UnsafeNativeMethods.SQLSetStmtAttrW(this, (int)attribute, value, (int)stringLength);
     ODBC.TraceODBC(3, "SQLSetStmtAttrW", retcode);
     return(retcode);
 }
Exemplo n.º 41
0
            int UnsafeNativeMethods.IPropertyBag.Read(string pszPropName, ref object pVar, UnsafeNativeMethods.IErrorLog pErrorLog) {
                Debug.WriteLineIf(AxHTraceSwitch.TraceVerbose, "Reading property " + pszPropName +  " from OCXState propertybag.");
                
                if (!bag.Contains(pszPropName))
                    return NativeMethods.E_INVALIDARG;

                pVar = bag[pszPropName];
                Debug.WriteLineIf(AxHTraceSwitch.TraceVerbose, "\tValue=" + ((pVar == null) ? "<null>" : pVar.ToString()));

                // The EE returns a VT_EMPTY for a null. The problem is that visual basic6 expects the caller to respect the
                // "hint" it gives in the VariantType. For eg., for a VT_BSTR, it expects that the callee will null
                // out the BSTR field of the variant. Since, the EE or us cannot do anything about this, we will return
                // a E_INVALIDARG rather than let visual basic6 crash.
                //
                return (pVar == null) ? NativeMethods.E_INVALIDARG : NativeMethods.S_OK;
            }
 /// <summary>
 /// Informs the developer if a particular model component type will require uniqueness within a document.
 /// This is currently true with render materials and model geometry; false otherwise.
 /// </summary>
 /// <param name="type">The type to check.</param>
 /// <returns>true with render materials and model geometry; false otherwise.</returns>
 /// <since>6.0</since>
 public static bool ModelComponentTypeRequiresUniqueName(ModelComponentType type)
 {
     return(UnsafeNativeMethods.ON_ModelComponent_RequiresUniqueName(type));
 }
Exemplo n.º 43
0
        private static void DoSetSearchPrefs(UnsafeNativeMethods.IDirectorySearch adsSearch, AdsSearchPreferenceInfo[] prefs)
        {
            int structSize = Marshal.SizeOf(typeof(AdsSearchPreferenceInfo));
            IntPtr ptr = Marshal.AllocHGlobal((IntPtr)(structSize * prefs.Length));
            try
            {
                IntPtr tempPtr = ptr;
                for (int i = 0; i < prefs.Length; i++)
                {
                    Marshal.StructureToPtr(prefs[i], tempPtr, false);
                    tempPtr = IntPtr.Add(tempPtr, structSize);
                }

                adsSearch.SetSearchPreference(ptr, prefs.Length);

                // Check for the result status for all preferences
                tempPtr = ptr;
                for (int i = 0; i < prefs.Length; i++)
                {
                    int status = Marshal.ReadInt32(tempPtr, 32);
                    if (status != 0)
                    {
                        int prefIndex = prefs[i].dwSearchPref;
                        string property = "";
                        switch (prefIndex)
                        {
                            case (int)AdsSearchPreferences.SEARCH_SCOPE:
                                property = "SearchScope";
                                break;
                            case (int)AdsSearchPreferences.SIZE_LIMIT:
                                property = "SizeLimit";
                                break;
                            case (int)AdsSearchPreferences.TIME_LIMIT:
                                property = "ServerTimeLimit";
                                break;
                            case (int)AdsSearchPreferences.ATTRIBTYPES_ONLY:
                                property = "PropertyNamesOnly";
                                break;
                            case (int)AdsSearchPreferences.TIMEOUT:
                                property = "ClientTimeout";
                                break;
                            case (int)AdsSearchPreferences.PAGESIZE:
                                property = "PageSize";
                                break;
                            case (int)AdsSearchPreferences.PAGED_TIME_LIMIT:
                                property = "ServerPageTimeLimit";
                                break;
                            case (int)AdsSearchPreferences.CHASE_REFERRALS:
                                property = "ReferralChasing";
                                break;
                            case (int)AdsSearchPreferences.SORT_ON:
                                property = "Sort";
                                break;
                            case (int)AdsSearchPreferences.CACHE_RESULTS:
                                property = "CacheResults";
                                break;
                            case (int)AdsSearchPreferences.ASYNCHRONOUS:
                                property = "Asynchronous";
                                break;
                            case (int)AdsSearchPreferences.TOMBSTONE:
                                property = "Tombstone";
                                break;
                            case (int)AdsSearchPreferences.ATTRIBUTE_QUERY:
                                property = "AttributeScopeQuery";
                                break;
                            case (int)AdsSearchPreferences.DEREF_ALIASES:
                                property = "DerefAlias";
                                break;
                            case (int)AdsSearchPreferences.SECURITY_MASK:
                                property = "SecurityMasks";
                                break;
                            case (int)AdsSearchPreferences.EXTENDED_DN:
                                property = "ExtendedDn";
                                break;
                            case (int)AdsSearchPreferences.DIRSYNC:
                                property = "DirectorySynchronization";
                                break;
                            case (int)AdsSearchPreferences.DIRSYNC_FLAG:
                                property = "DirectorySynchronizationFlag";
                                break;
                            case (int)AdsSearchPreferences.VLV:
                                property = "VirtualListView";
                                break;
                        }
                        throw new InvalidOperationException(Res.GetString(Res.DSSearchPreferencesNotAccepted, property));
                    }

                    tempPtr = IntPtr.Add(tempPtr, structSize);
                }
            }
            finally
            {
                Marshal.FreeHGlobal(ptr);
            }
        }
 /// <summary>
 /// Informs the developer if a particular model component type will require case-ignoring searching within a document.
 /// This is currently true with groups; false otherwise.
 /// </summary>
 /// <param name="type">True if the component ignores case.</param>
 /// <since>6.0</since>
 public static bool ModelComponentTypeIgnoresCase(ModelComponentType type)
 {
     return(UnsafeNativeMethods.ON_ModelComponent_UniqueNameIgnoresCase(type));
 }
 bool GetBool(UnsafeNativeMethods.FileWriteOptionsBoolConsts which)
 {
   return UnsafeNativeMethods.CRhinoFileWriteOptions_GetBool(m_ptr, which);
 }
 /// <summary>
 /// Informs the developer if a particular model component type will include the hash of the parent.
 /// </summary>
 /// <param name="type">True if the component includes parent hash.</param>
 /// <since>6.0</since>
 public static bool ModelComponentTypeIncludesParent(ModelComponentType type)
 {
     return(UnsafeNativeMethods.ON_ModelComponent_UniqueNameIncludesParent(type));
 }
Exemplo n.º 47
0
 int UnsafeNativeMethods.IOleClientSite.GetContainer(out UnsafeNativeMethods.IOleContainer container) 
 {
     container = this.Host.Container;
     return NativeMethods.S_OK;
 }
Exemplo n.º 48
0
 /// <summary>
 /// Is called when the object associated with this data is transformed. If you override this
 /// function, make sure to call the base class if you want the stored Transform to be updated.
 /// </summary>
 /// <param name="transform">The transform being applied.</param>
 protected virtual void OnTransform(Geometry.Transform transform)
 {
     UnsafeNativeMethods.ON_UserData_OnTransform(m_native_pointer, ref transform);
 }
Exemplo n.º 49
0
        internal int CallISAPI(UnsafeNativeMethods.CallISAPIFunc iFunction, byte [] bufIn, byte [] bufOut) {

            if (_wr == null || !(_wr is System.Web.Hosting.ISAPIWorkerRequest))
                throw new HttpException(SR.GetString(SR.Cannot_call_ISAPI_functions));
#if !FEATURE_PAL // FEATURE_PAL does not enable IIS-based hosting features
            return ((System.Web.Hosting.ISAPIWorkerRequest) _wr).CallISAPI(iFunction, bufIn, bufOut);
#else // !FEATURE_PAL
                throw new NotImplementedException ("ROTORTODO");
#endif // !FEATURE_PAL
        }
Exemplo n.º 50
0
        /// <summary>
        /// Checks for the existence of a specific type of userdata in this list
        /// Both .NET and native userdata is checked
        /// </summary>
        /// <param name="userdataId"></param>
        /// <returns></returns>
        public bool Contains(Guid userdataId)
        {
            IntPtr const_ptr_onobject = m_parent.ConstPointer();

            return(UnsafeNativeMethods.CRhCmnUserData_Contains(const_ptr_onobject, userdataId));
        }
Exemplo n.º 51
0
 private static string TranslateReturnCode(UnsafeNativeMethods.CredUIReturnCodes result)
 {
     return string.Format(CultureInfo.CurrentUICulture, Properties.Resources.CredUIReturn, result.ToString());
 }
Exemplo n.º 52
0
        /// <summary>
        /// Removes all user data from this geometry.
        /// </summary>
        /// <remarks>User <see cref="Remove"/> to delete a single, known, item.</remarks>
        public void Purge()
        {
            IntPtr non_const_ptr_onobject = m_parent.NonConstPointer();

            UnsafeNativeMethods.ON_UserData_PurgeUserData(non_const_ptr_onobject);
        }
Exemplo n.º 53
0
 public static extern int RegisterDragDrop(HandleRef hwnd, UnsafeNativeMethods.IOleDropTarget target);
        public static DataFormat GetDataFormat(string format)
        {
            if (format == null)
            {
                throw new ArgumentNullException("format");
            }

            if (format == string.Empty)
            {
                throw new ArgumentException(SR.Get(SRID.DataObject_EmptyFormatNotAllowed));
            }

            // Ensures the predefined Win32 data formats into our format list.
            EnsurePredefined();

            // Lock the data format list to obtains the mutual-exclusion.
            lock (_formatListlock)
            {
                int formatId;
                int index;

                // It is much faster to do a case sensitive search here.  So do
                // the case sensitive compare first, then the expensive one.
                //
                for (int n = 0; n < _formatList.Count; n++)
                {
                    DataFormat formatItem;

                    formatItem = (DataFormat)_formatList[n];

                    if (formatItem.Name.Equals(format))
                    {
                        return(formatItem);
                    }
                }

                for (int n = 0; n < _formatList.Count; n++)
                {
                    DataFormat formatItem;

                    formatItem = (DataFormat)_formatList[n];

                    if (String.Compare(formatItem.Name, format, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        return(formatItem);
                    }
                }

                // In the most cases the default formats return earlier. If we got here
                // then this is an attempt to register a new format which is not ok in partial trust.
                SecurityHelper.DemandUnmanagedCode();
                // Reigster the this format string.
                formatId = UnsafeNativeMethods.RegisterClipboardFormat(format);

                if (formatId == 0)
                {
                    throw new System.ComponentModel.Win32Exception();
                }

                index = _formatList.Add(new DataFormat(format, formatId));

                return((DataFormat)_formatList[index]);
            }
        }
Exemplo n.º 55
0
 public static extern UnsafeNativeMethods.IStorage StgOpenStorageOnILockBytes(UnsafeNativeMethods.ILockBytes iLockBytes, UnsafeNativeMethods.IStorage pStgPriority, int grfMode, int sndExcluded, int reserved);
Exemplo n.º 56
0
 /// <summary>
 /// Invokes the operation OnDataAvailable on the <see cref="DataReaderListener" /> objects attached to contained <see cref="DataReader" />
 /// entities with a <see cref="StatusKind.DataAvailableStatus" /> that is considered changed.
 /// </summary>
 /// <remarks>
 /// This operation is typically invoked from the OnDataOnReaders operation in the <see cref="SubscriberListener" />. That way the
 /// <see cref="SubscriberListener" /> can delegate to the <see cref="DataReaderListener" /> objects the handling of the data.
 /// </remarks>
 /// <returns>The <see cref="ReturnCode" /> that indicates the operation result.</returns>
 public ReturnCode NotifyDataReaders()
 {
     return(UnsafeNativeMethods.NotifyDataReaders(_native));
 }
        static unsafe string EncodeObject(ref object data, UnsafeNativeMethods.EventData* dataDescriptor, byte* dataBuffer)        
        {
            dataDescriptor->Reserved = 0;

            string sRet = data as string;
            if (sRet != null)
            {
                dataDescriptor->Size = (uint)((sRet.Length + 1) * 2);
                return sRet;
            }

            if (data is IntPtr)
            {
                dataDescriptor->Size = (uint)sizeof(IntPtr);
                IntPtr* intptrPtr = (IntPtr*)dataBuffer;
                *intptrPtr = (IntPtr)data;
                dataDescriptor->DataPointer = (ulong)intptrPtr;
            }
            else if (data is int)
            {
                dataDescriptor->Size = (uint)sizeof(int);
                int* intptrPtr = (int*)dataBuffer;
                *intptrPtr = (int)data;
                dataDescriptor->DataPointer = (ulong)intptrPtr;
            }
            else if (data is long)
            {
                dataDescriptor->Size = (uint)sizeof(long);
                long* longptr = (long*)dataBuffer;
                *longptr = (long)data;
                dataDescriptor->DataPointer = (ulong)longptr;
            }
            else if (data is uint)
            {
                dataDescriptor->Size = (uint)sizeof(uint);
                uint* uintptr = (uint*)dataBuffer;
                *uintptr = (uint)data;
                dataDescriptor->DataPointer = (ulong)uintptr;
            }
            else if (data is UInt64)
            {
                dataDescriptor->Size = (uint)sizeof(ulong);
                UInt64* ulongptr = (ulong*)dataBuffer;
                *ulongptr = (ulong)data;
                dataDescriptor->DataPointer = (ulong)ulongptr;
            }
            else if (data is char)
            {
                dataDescriptor->Size = (uint)sizeof(char);
                char* charptr = (char*)dataBuffer;
                *charptr = (char)data;
                dataDescriptor->DataPointer = (ulong)charptr;
            }
            else if (data is byte)
            {
                dataDescriptor->Size = (uint)sizeof(byte);
                byte* byteptr = (byte*)dataBuffer;
                *byteptr = (byte)data;
                dataDescriptor->DataPointer = (ulong)byteptr;
            }
            else if (data is short)
            {
                dataDescriptor->Size = (uint)sizeof(short);
                short* shortptr = (short*)dataBuffer;
                *shortptr = (short)data;
                dataDescriptor->DataPointer = (ulong)shortptr;
            }
            else if (data is sbyte)
            {
                dataDescriptor->Size = (uint)sizeof(sbyte);
                sbyte* sbyteptr = (sbyte*)dataBuffer;
                *sbyteptr = (sbyte)data;
                dataDescriptor->DataPointer = (ulong)sbyteptr;
            }
            else if (data is ushort)
            {
                dataDescriptor->Size = (uint)sizeof(ushort);
                ushort* ushortptr = (ushort*)dataBuffer;
                *ushortptr = (ushort)data;
                dataDescriptor->DataPointer = (ulong)ushortptr;
            }
            else if (data is float)
            {
                dataDescriptor->Size = (uint)sizeof(float);
                float* floatptr = (float*)dataBuffer;
                *floatptr = (float)data;
                dataDescriptor->DataPointer = (ulong)floatptr;
            }
            else if (data is double)
            {
                dataDescriptor->Size = (uint)sizeof(double);
                double* doubleptr = (double*)dataBuffer;
                *doubleptr = (double)data;
                dataDescriptor->DataPointer = (ulong)doubleptr;
            }
            else if (data is bool)
            {
                dataDescriptor->Size = (uint)sizeof(bool);
                bool* boolptr = (bool*)dataBuffer;
                *boolptr = (bool)data;
                dataDescriptor->DataPointer = (ulong)boolptr;
            }
            else if (data is Guid)
            {
                dataDescriptor->Size = (uint)sizeof(Guid);
                Guid* guidptr = (Guid*)dataBuffer;
                *guidptr = (Guid)data;
                dataDescriptor->DataPointer = (ulong)guidptr;
            }
            else if (data is decimal)
            {
                dataDescriptor->Size = (uint)sizeof(decimal);
                decimal* decimalptr = (decimal*)dataBuffer;
                *decimalptr = (decimal)data;
                dataDescriptor->DataPointer = (ulong)decimalptr;
            }
            else if (data is Boolean)
            {
                dataDescriptor->Size = (uint)sizeof(Boolean);
                Boolean* booleanptr = (Boolean*)dataBuffer;
                *booleanptr = (Boolean)data;
                dataDescriptor->DataPointer = (ulong)booleanptr;
            }
            else
            {
                // Everything else is a just a string
                sRet = data.ToString();
                dataDescriptor->Size = (uint)((sRet.Length + 1) * 2);
                return sRet;
            }

            return null;
        }
Exemplo n.º 58
0
 /// <summary>
 /// Indicates that the application is about to access the data samples in any of the <see cref="DataReader" /> objects attached to
 /// the <see cref="Subscriber" />.
 /// </summary>
 /// <remarks>
 /// <para>The application is required to use this operation only if <see cref="PresentationQosPolicy" /> of the <see cref="Subscriber" /> to which the
 /// <see cref="DataReader" /> belongs has the <see cref="PresentationQosPolicy.AccessScope" /> set to
 /// <see cref="PresentationQosPolicyAccessScopeKind.GroupPresentationQos" />.</para>
 /// <para>In the aforementioned case, the operation BeginAccess must be called prior to calling any of the sample-accessing operations,
 /// namely: GetDataReaders on the <see cref="Subscriber" /> and Read, Take on any <see cref="DataReader" />.
 /// Otherwise the sample-accessing operations will return the error <see cref="ReturnCode.PreconditionNotMet" />. Once the application has
 /// finished accessing the data samples it must call <see cref="EndAccess" />.</para>
 /// <para>The calls to BeginAccess/<see cref="EndAccess" /> may be nested. In that case, the application must call <see cref="EndAccess" /> as many times as it
 /// called BeginAccess.</para>
 /// </remarks>
 /// <returns>The <see cref="ReturnCode" /> that indicates the operation result.</returns>
 public ReturnCode BeginAccess()
 {
     return(UnsafeNativeMethods.BeginAccess(_native));
 }
Exemplo n.º 59
0
 /// <summary>
 /// Shows the UI.
 /// </summary>
 /// <param name="dwID">The dw ID.</param>
 /// <param name="activeObject">The active object.</param>
 /// <param name="commandTarget">The command target.</param>
 /// <param name="frame">The frame.</param>
 /// <param name="doc">The doc.</param>
 /// <returns></returns>
 public int ShowUI(
     int dwID,
     UnsafeNativeMethods.IOleInPlaceActiveObject activeObject,
     NativeMethods.IOleCommandTarget commandTarget,
     UnsafeNativeMethods.IOleInPlaceFrame frame,
     UnsafeNativeMethods.IOleInPlaceUIWindow doc)
 {
     // default means we don't have any UI, and control should show its UI
     return NativeMethods.SRESULTS.S_FALSE;
 }
Exemplo n.º 60
0
 /// <summary>
 /// Indicates that the application has finished accessing the data samples in <see cref="DataReader" /> objects managed by the <see cref="Subscriber" />.
 /// </summary>
 /// <remarks>
 /// <para>This operation must be used to 'close' a corresponding <see cref="BeginAccess" />.</para>
 /// <para>After calling EndAccess the application should no longer access any of the data or <see cref="SampleInfo" /> elements returned from the
 /// sample-accessing operations. This call must close a previous call to <see cref="BeginAccess" /> otherwise the operation will return the error
 /// <see cref="ReturnCode.PreconditionNotMet" />.</para>
 /// </remarks>
 /// <returns>The <see cref="ReturnCode" /> that indicates the operation result.</returns>
 public ReturnCode EndAccess()
 {
     return(UnsafeNativeMethods.EndAccess(_native));
 }