biase Posted December 25, 2011 Posted December 25, 2011 (edited) I have found a site that can create a dat file here.I don't know other scripting language and only know autoit language a bit.I'm new to this dll with autoit, can some one please translate it to autoitexpandcollapse popup//WPFormat using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; namespace WP.WpFormat { public class WpFormat { [DllImport("WpFormat.dll")] public static extern System.IntPtr MRGInitDataFile(Byte bWPVersion, [MarshalAs(UnmanagedType.LPStr)] StringBuilder lpszFileName); [DllImport("WpFormat.dll")] public static extern void MRGCreateFieldNames(System.IntPtr handle, [MarshalAs(UnmanagedType.LPStr)] StringBuilder fielNames, int fieldCount); [DllImport("wpFormat.dll")] public static extern bool MRGAddField(System.IntPtr handle, [MarshalAs(UnmanagedType.LPStr)] StringBuilder lpszField); [DllImport("wpFormat.dll")] public static extern void MRGEndRecord(System.IntPtr handle); [DllImport("wpFormat.dll")] public static extern void MRGCloseDataFile(System.IntPtr handle); } } //Client Application using System; using System.Collections.Generic; using System.Text; using System.Runtime.InteropServices; using System.IO; using WP.WpFormat; namespace WPTestApp { class Program { static void Main(string[] args) { StringBuilder fileNameSb= new StringBuilder(); fileNameSb.Append(@"c:Test.dat"); System.IntPtr handle = WpFormat.MRGInitDataFile(1, fileNameSb); StringBuilder fieldNamesSb = new StringBuilder(); fieldNamesSb.Append("Name;Contact"); WpFormat.MRGCreateFieldNames(handle, fieldNamesSb, 2); StringBuilder fieldValuesb = new StringBuilder(); fieldValuesb.Append("JOHN"); WpFormat.MRGAddField(handle, fieldValuesb); fieldValuesb=new StringBuilder(); fieldValuesb.Append("123-123-1231"); WpFormat.MRGAddField(handle, fieldValuesb); WpFormat.MRGEndRecord(handle); WpFormat.MRGCloseDataFile(handle); } } } Edited December 25, 2011 by biase
smartee Posted December 26, 2011 Posted December 26, 2011 hi lookup the Dll functions in the help file. Then.. see if you follow this (no error-checking),$hDll = DllOpen("WPFormat.dll") $aRet = DllCall($hDll, "int_ptr", "MRGInitDataFile", "byte", 1, "str", "test.dat") DllCall($hDll, "none", "MRGCreateFieldNames", "int_ptr", $aRet[0], "str", "Name;Contact", "int", 2) DllCall($hDll, "bool", "MRGAddField", "int_ptr", $aRet[0], "str", "JOHN") DllCall($hDll, "bool", "MRGAddField", "int_ptr", $aRet[0], "str", "123-123-1231") DllCall($hDll, "none", "MRGEndRecord", "int_ptr", $aRet[0]) DllCall($hDll, "none", "MRGCloseDataFile", "int_ptr", $aRet[0]) DllClose($hDll) Good luck.
biase Posted January 8, 2012 Author Posted January 8, 2012 It's works, thanks smartee... now i can learn a little about dllopen
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now