示例#1
0
        public static int ExecuteFileW(IntPtr mainWin, IntPtr remoteName, [MarshalAs(UnmanagedType.LPWStr)] string verb)
        {
            var rmtName = Marshal.PtrToStringUni(remoteName);
            var result  = ExecuteFileInternal(mainWin, rmtName, verb);

            if (result.Type == ExecResult.ExecEnum.SymLink && result.SymlinkTarget.HasValue)
            {
                TcUtils.WriteStringUni(result.SymlinkTarget, remoteName, 0);
            }

            return((int)result.Type);
        }
示例#2
0
        public static bool GetLocalNameW(IntPtr remoteName, int maxLen)
        {
            var rmtName = Marshal.PtrToStringUni(remoteName);

            var result = GetLocalNameInternal(ref rmtName, maxLen);

            if (result)
            {
                TcUtils.WriteStringUni(rmtName, remoteName, 0);
            }

            return(result);
        }
示例#3
0
        public static int GetPreviewBitmapW(IntPtr remoteName, int width, int height, IntPtr returnedBitmap)
        {
            var rmtName   = Marshal.PtrToStringUni(remoteName);
            var inRmtName = rmtName;
            var result    = GetPreviewBitmapInternal(ref rmtName, width, height, returnedBitmap);

            if (result != PreviewBitmapResult.PreviewBitmapEnum.None && !string.IsNullOrEmpty(rmtName) && !rmtName.Equals(inRmtName, StringComparison.CurrentCultureIgnoreCase))
            {
                TcUtils.WriteStringUni(rmtName, remoteName, 0);
            }

            return((int)result);
        }
示例#4
0
        public static int ExtractCustomIconW(IntPtr remoteName, int extractFlags, IntPtr theIcon)
        {
            var rmtName   = Marshal.PtrToStringUni(remoteName);
            var inRmtName = rmtName;
            var result    = ExtractIconInternal(ref rmtName, extractFlags, theIcon);

            if (result != ExtractIconResult.ExtractIconEnum.UseDefault && !rmtName.Equals(inRmtName, StringComparison.CurrentCultureIgnoreCase))
            {
                TcUtils.WriteStringUni(rmtName, remoteName, 0);
            }

            return((int)result);
        }
示例#5
0
        public static int PutFileW([MarshalAs(UnmanagedType.LPWStr)] string localName, IntPtr remoteName, int copyFlags)
        {
            var rmtName   = Marshal.PtrToStringUni(remoteName);
            var inRmtName = rmtName;
            var result    = PutFileInternal(localName, ref rmtName, (CopyFlags)copyFlags);

            if (result == FileSystemExitCode.OK && !rmtName.Equals(inRmtName, StringComparison.CurrentCultureIgnoreCase))
            {
                TcUtils.WriteStringUni(rmtName, remoteName, 0);
            }

            return((int)result);
        }
示例#6
0
        public static bool GetDefaultViewW(IntPtr viewContents, IntPtr viewHeaders, IntPtr viewWidths, IntPtr viewOptions, int maxLen)
        {
            var result = GetDefaultViewFs(out var contents, out var headers, out var widths, out var options, maxLen);

            if (result)
            {
                TcUtils.WriteStringUni(contents, viewContents, maxLen);
                TcUtils.WriteStringUni(headers, viewHeaders, maxLen);
                TcUtils.WriteStringUni(widths, viewWidths, maxLen);
                TcUtils.WriteStringUni(options, viewOptions, maxLen);

                return(true);
            }

            return(false);
        }
示例#7
0
        public void CopyTo(IntPtr ptr)
        {
            if (ptr != IntPtr.Zero && changed)
            {
                switch (FieldType)
                {
                case ContentFieldType.Numeric32:
                    Marshal.WriteInt32(ptr, Int32.Parse(strValue));
                    break;

                case ContentFieldType.Numeric64:
                    Marshal.WriteInt64(ptr, Int64.Parse(strValue));
                    break;

                case ContentFieldType.NumericFloating:
                    string altStr   = null;
                    string floatStr = strValue;
                    if (floatStr.Contains("|"))
                    {
                        int pos = floatStr.IndexOf("|", StringComparison.Ordinal);
                        altStr   = floatStr.Substring(pos + 1);
                        floatStr = floatStr.Substring(0, pos);
                    }
                    Marshal.Copy(new[] { Double.Parse(floatStr) }, 0, ptr, 1);
                    if (!String.IsNullOrEmpty(altStr))
                    {
                        // ??? ANSI or Unicode
                        IntPtr altOutput = new IntPtr(ptr.ToInt32() + sizeof(Double));
                        Marshal.Copy((altStr + (Char)0).ToCharArray(), 0, altOutput, altStr.Length + 1);
                    }
                    break;

                case ContentFieldType.Date:
                    DateTime date = DateTime.Parse(strValue);
                    Marshal.Copy(new[] { (Int16)date.Year, (Int16)date.Month, (Int16)date.Day }, 0, ptr, 3);
                    break;

                case ContentFieldType.Time:
                    DateTime time = DateTime.Parse(strValue);
                    Marshal.Copy(new[] { (Int16)time.Hour, (Int16)time.Minute, (Int16)time.Second }, 0, ptr, 3);
                    break;

                case ContentFieldType.Boolean:
                    Marshal.WriteInt32(ptr, Boolean.Parse(strValue) ? 1 : 0);
                    break;

                case ContentFieldType.MultipleChoice:
                case ContentFieldType.String:
                    TcUtils.WriteStringAnsi(strValue, ptr, 0);
                    break;

                case ContentFieldType.FullText:
                    // ??? can it be Unicode ???
                    TcUtils.WriteStringAnsi(strValue, ptr, 0);
                    break;

                case ContentFieldType.DateTime:
                    Marshal.WriteInt64(ptr, DateTime.Parse(strValue).ToFileTime());
                    break;

                case ContentFieldType.WideString:
                    TcUtils.WriteStringUni(strValue, ptr, 0);
                    break;
                }
            }
        }