;ini file library ;modified sept 30, 2003 to eliminate need for buffer Global Buffer.s Global IniFile.s Global MemID.l Global MainPath.s ProcedureDLL BrowsePath(P$) Buffer=PathRequester("Please select a path to explore",P$) ProcedureReturn @Buffer EndProcedure ProcedureDLL.l ChooseColor() ProcedureReturn ColorRequester() EndProcedure ProcedureDLL BrowseFile(F$) P$=GetExtensionPart(F$) If LCase(P$)="txt" P$="Text Files|*.txt|All Files|*.*" ElseIf LCase(P$)="x" P$="X - Files|*.x|3DS files|*.3ds|All Files|*.*" Else P$=P$+" File|*."+P$+"|Any File|*.*" EndIf Buffer=OpenFileRequester("Please select a file",F$,P$,0) ProcedureReturn @Buffer EndProcedure ProcedureDLL SaveAFile(F$) P$=GetExtensionPart(F$) If LCase(P$)="txt" P$="Text File|*.txt|Any File|*.*" ElseIf LCase(p$)="x" P$="X - File|*.x|Any File|*.*" ElseIf LCase(P$)="bmp" P$="Bitmap File|*.bmp|Any File|*.*" Else P$=P$+" File|*."+P$+"|Any File|*.*" EndIf Buffer=SaveFileRequester("Save file as",F$,P$,0) EndProcedure ProcedureDLL GetCurrentpath() hMod = GetModuleHandle_(0) MainPath = Space(255) GetModuleFilename_(hMod,@MainPath,255) MainPath=GetPathPart(MainPath) ProcedureReturn @MainPath EndProcedure Procedure SetForground() If GetForegroundWindow_()<>WindowID() SetForegroundWindow_(WindowID()) EndIf EndProcedure ProcedureDLL SelectIniFile(*Filename) If FileSize(PeekS(*FileName))<0 IniFile=PeekS(*FileName) Else IniFile=MainPath+PeekS(*FileName) EndIf If FileSize(IniFile)<0 MessageRequester("Ini File Error","Unable to locate file = "+IniFile,#MB_ICONINFORMATION) EndIf EndProcedure ProcedureDLL GetString(Section.s,Key.s,D.s) Buffer=Space(255) getprivateprofilestring_(Section,Key,D,@Buffer,255,IniFile) ProcedureReturn @Buffer EndProcedure ProcedureDLL.l GetInt(Section.s,Key.s,d.l) ProcedureReturn getprivateprofileint_(Section,Key,d,IniFile) EndProcedure ProcedureDLL WriteIniString(Section.s,Key.s,String.s) If Len(String) WritePrivateProfileString_(Section,Key,String,IniFile) Else WritePrivateProfileString_(Section,Key,Chr(0)+Chr(0),IniFile) EndIf EndProcedure ProcedureDLL WriteInt(Section.s,Key.s,D.l) writeprivateprofilestring_(Section,Key,Str(D),IniFile) EndProcedure ProcedureDLL BlockWriteInt(Section.s,Key.s,D.l) If D writeprivateprofilestring_(Section,Key,Str(D),IniFile) Else writeprivateprofilestring_(Section,Key,Chr(0)+Chr(0),IniFile) EndIf EndProcedure ProcedureDLL RemoveSection(Section.s) writeprivateprofilestring_(Section,Chr(0)+Chr(0),NULL,IniFile) EndProcedure ProcedureDLL RemoveKey(Section.s,Key.s) writeprivateprofilestring_(Section,Key,Chr(0)+Chr(0),IniFile) EndProcedure ProcedureDLL.l ShowText(T.s,M.s,F.l) ProcedureReturn MessageRequester(T,M,F) EndProcedure ProcedureDLL ShowMsgBoxConstants() msg.s="Icons:"+Chr(10) msg=msg+"#MB_ICONSTOP ="+Str(#MB_ICONSTOP)+Chr(10) msg=msg+"#MB_ICONQUESTION ="+Str(#MB_ICONQUESTION)+Chr(10) msg=msg+"#MB_ICONEXCLAMATION ="+Str(#MB_ICONEXCLAMATION)+Chr(10) msg=msg+"#MB_ICONASTERISK ="+Str(#MB_ICONASTERISK)+Chr(10) msg=msg+"#MB_ICONINFORMATION ="+Str(#MB_ICONINFORMATION)+Chr(10) msg=msg+"Styles:"+Chr(10) msg=msg+"#YesNo ="+Str(#PB_MessageRequester_YesNo)+Chr(10) msg=msg+"#YesNoCancel ="+Str(#PB_MessageRequester_YesNoCancel)+Chr(10) msg=msg+"Replys:"+Chr(10) msg=msg+"Yes = 6, No=7, Cancel=2" MessageRequester("Message Box Flags",msg,0) EndProcedure ProcedureDLL AboutIni(C.s,T.s) msg.s=T+Chr(10) msg=msg+"Date ="+FormatDate("%yyyy,%mm,%dd",#PB_COMPILER_DATE)+Chr(10) msg=msg+"Time ="+FormatDate("%hh:%ii:%ss",#PB_COMPILER_DATE)+Chr(10) msg=msg+"Norms Ini File DLL" MessageRequester(C,msg,0) EndProcedure ; ExecutableFormat=Shared Dll ; EnableAsm ; Executable=C:\Program Files\PureBasic\Projects\Mapper\MyIni.dll ; EOF