Beispiel #1
0
        public static int PtrForFunc(string dll, string method)
        {
            IntPtr dllLook;

            if ((dllLook = DllImportCaller.lookupDll(dll)) != IntPtr.Zero)
            {
                IntPtr methodLookup;
                if ((methodLookup = DllImportCaller.lookupMethod(dllLook, method)) != IntPtr.Zero)
                {
                    return(methodLookup.ToInt32());
                    //EXECUTE / OK
                }
                else
                {
                    DllImportCaller.lib.FreeLibrary7(dllLook);
                    throw new Exception("Could not find Method (Dll found)");
                }
            }
            else
            {
                throw new Exception("Could not find dll (" + dll + ")");
            }

            throw new InvalidOperationException();
        }
Beispiel #2
0
                    public static Directory7[] OpenDirectory(string fullFolderName)
                    {
                        WIN32_FIND_DATA data;
                        var             handle = DllImportCaller.lib.FindFirstFile7(fullFolderName, out data);

                        if (handle == -1)
                        {
                            var err = DllImportCaller.LastError().ToString();

                            if (err == "-2147483643")
                            {
                                throw new System.IO.IOException("Forbidden or not exist");
                            }
                            else
                            {
                                throw new Exception(err);
                            }
                        }

                        var list = new List <Directory7>();

                        list.Add(new Directory7(data, fullFolderName, true)); //add first defined "out data"


                        int next;

                        while ((next = DllImportCaller.lib.FindNextFile7(handle, out data)) != 0)
                        {
                            list.Add(new Directory7(data, System.IO.Path.Combine(fullFolderName, data.cFileName), false));//continue to add
                        }

                        var r = DllImportCaller.lib.FindClose7(handle);

                        return(list.ToArray());
                    }
Beispiel #3
0
                public static File7 Open(string fullPath, string mode)
                {
                    int handle = DllImportCaller.lib.fopen7(fullPath, mode);

                    if (handle == 0)
                    {
                        throw new Exception(DllImportCaller.LastError().ToString());
                    }

                    return(new File7(handle));
                }
Beispiel #4
0
                public int GetFileSize()
                {
                    checkDisposed();

                    int val = DllImportCaller.lib.fsize7(Handle);

                    if (val == -1)
                    {
                        throw new Exception(DllImportCaller.LastError().ToString());
                    }

                    return(val);
                }