PDA

View Full Version : kernel32.dll, CreateFileW, Unicode, help anyone?



coderanger
02-12-2007, 04:46 AM
Hi Gang,

This is probably a question for the more experienced C/C++ programmers
here..

There's a game/simulator I play every now and again, and it has files that
can be edited by the end user to accomplish certain things. So, I thought
it would be nice to create a program that could create these files so it
would be faster and easier for me to do what I want to do.

Anyway, so I create my little application in AMS6, everything seems to
work great, except the files I create and import into the game/sim give
me the old file is corrupt error message, then the game/sim shuts down.

Well, it took my brain a little while to kick in, but it finally dawns on me
that the files that we can import and use for this game need to be in
Unicode format, and I think "Well, my little app is not exporting in Unicode."

So, after doing about a weeks worth of searching and research, I have come
to the conclusion that I need to be using the Windows kernel32.dll dynamic
link library to export my files in Unicode format.

The closest I can come to finding any useful information on using the
functions in this file (I think specifically CreateFileW) are from this website:

http://source.winehq.org/WineAPI/CreateFileW.html
http://source.winehq.org/WineAPI/kernel32.html

That's really as far as I can get. I cannot find a website or information for
the really dumb (speaking of myself) to understand how in the world to
implement this into my AMS6 program and export a file in Unicode format.

Is there anyone kind enough to give me a small example of getting this to
work in my app?

Any help would be greatly appreciated.
Patrick

Buffman
02-12-2007, 12:44 PM
Hi coderanger,

This (http://www.indigorose.com/forums/showthread.php?t=17402&highlight=unicode) may help you out...

coderanger
02-12-2007, 01:35 PM
Thanks Buffman,

I'm not having any luck with that, I'm not sure I'm using it properly though..
Here's what's supplied in that program:


--[[ The function inside of the DLL is ANSUNI. The only argument is the "string" you suppy to get converted
Try this out and let me know if it works properly, if you would. I ported it from another language for AMS users to use]]

result = DLL.CallFunction("AutoPlay\\Docs\\DLLANSI2UNI.dll", "ANSUNI", "PUT_YOUR_ANSI_STRING_HERE", DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);

So, I added this just to test it out..


TextFile.WriteFromString("C:\\MyGameCodeFile.txt", result, false);

The file I get is unreadable.. In fact, it's only one character, this: 0

So, I'm either doing something wrong, or it's not working as it should. The
only instructions I've got to go on are the ones supplied with the help
docs.

Any help would be appreciated.

Thanks,
Patrick

coderanger
02-12-2007, 01:46 PM
Just tried this too, and it didn't work:


tProperties = {};
tProperties.Enabled = true;
tProperties.Visible = true;
tProperties.FontScript = 0; --Apparently, setting this to 0 sets the text to ANSI
tProperties.Text = Input.GetText("Input1");
-- Set the properties of an input object
Input.SetProperties("Input1", tProperties);
result = Input.GetText("Input1");
result = DLL.CallFunction("AutoPlay\\Docs\\DLLANSI2UNI.dll", "ANSUNI", result, DLL_RETURN_TYPE_LONG, DLL_CALL_STDCALL);
TextFile.WriteFromString("C:\\MyGameCodeFile.txt", result, false);

Patrick