C++ :: Unicode And Win32 API Functions
Aug 11, 2014
You told me that it's better to use UNICODE all the time.
What if the Win32 Api function doesn't have a UNICODE version.
For example CryptProtectData() takes a BYTE (DATA_BLOB *) which is an unsigned char?
[Code] ......
View 7 Replies
ADVERTISEMENT
Nov 20, 2012
Working in Win32 console app (VS 2010) I have been trying to convert several Unicode (UTF-16) C++ functions to Ansi C (UTF-8). The test app includes two tokenizer classes, each of which work perfectly well in their respective environments, CTokA and CTokW (UTF-8 and UTF-16).
A problem arises when I attempt to run the UTF-8 functions when the Character Set properties is set to 'Use Unicode Character Set' in that std::string manipulations do not perform as expected, e.g.,
printf("start
");
gets reproduced as
printf("start
");══════════ ²²²²
Attempting to null terminate the string where it is supposed to end simply results in a space in that position and the garbage end persists, e.g.,
printf("sta t
");══════════ ²²²²
Code:
sline[11] = 0x0000;
If I attempt to change the Character Set property to 'Use Multibyte Character Set' or 'Not Set', the app will not compile and hundreds of errors occur. Of course, I can eliminate all of the UTF-16 code, but it strikes me that it should not be necessary. Perhaps if M$ made everything UTF-16 without all of the necessary decorations like 'L' and '_T(', life would be much simpler. Unfortunately, I have a very extensive UTF-8 app under 10 years of development that works quite well, but my UTF-16 (Unicode) conversion doesnt work as well because of the mixing of pointers (I think), so I have had to revert much of the code back to UTF-8. (All of which has nothing to do with my question but is simply psychotheraputic for me to ventilate on.)
My question is this: Can UTF-8 and UTF-16 code coexist in a single Win32 console app?
View 6 Replies
View Related
Aug 29, 2013
I have some code that was compiled without Unicode turned on in the Preprocessor Definitions. I need to access an API that had Unicode turned on in the Preprocessor Definitions (I believe that it is on by default for DLL's) .
I need to call a function in the DLL that requires a structure like:
struct READERINFO {
TCHAR serial[32];
TCHAR altSerial[32];
TCHAR name[32];
TCHAR fccId[48];
TCHAR hwVersion[16];
int swVerMajor;
int swVerMinor;
char devBuild;
};
It returns some information in the structure some of it is Unicode based however the program that is calling it is not Unicode. The preprocessors are not turned on because if they were there would be a lot of things to change in this code. The code is old code that I inherited and now I must interface to some new devices.
I declare my structure as :
READERINFO info; Then I call the function in the DLL which looks like: ApiGetReaderInfo(hAPI, &info, sizeof(into));
Which is defined as:
ApiGetReaderInfo(HANDLE hApi,
Struct READERINFO * ri,
DWORD riSize);
Parameters:
hApiHandle to valid Api object instance
riPointer to the READERINFO structure.
riSizeSize of ri structure in bytes. Usually: sizeof(struct READERINFO).
When I call it from my program that does not have UNICODE defined in the Pre-Processors I get :
Characters like : ÌÌÌÌÌ in the TCHAR fields and invalid numbers in the integer fields.
int ModuleVersion(HANDLE hApi) {
struct READERINFO info;
ApiGetReaderInfo(hApi, &info, sizeof(info));
[Code] ....
When I call it from my program that has some sample code just for this and has the UNICODE defined in the Preprocessors it works just fine. how I can call this from my old code and get the correct information. I have already tried to do the follow without success:
int ModuleVersion(HANDLE hApi) {
#define UNICODE
struct READERINFO info;
#undef UNICODE
ApiGetReaderInfo(hApi, &info, sizeof(info));
[Code] .....
View 4 Replies
View Related
Jan 28, 2014
I want to show and control mouse in Win32 Console. What should I do? And I want to learn MFC programing.
View 3 Replies
View Related
Feb 15, 2014
That is my routine to catch a text from editBox (ID_EDIT2) and save in a file. The address of file is in (ID_EDIT1). The code is working.
void simplewrite(HWND hwnd){
HANDLE hFile;
DWORD dwWritten;
[Code]....
My problem is: I put the size of char array txtbuffer=[200]. If I have a editbox bigger than that, I'll get a error. In (editlength) I have the correct length of edit box. But I cant initialize my char txtbuffer[editglenth]=NULL cause editlength is a integer not constant.
View 2 Replies
View Related
Dec 18, 2012
I understand including the comctrl32 lib and header. I know to init common controls. I can create a tab window and add tabs to it.
I just can't seem to grasp of how to tell when a specific tab has been selected. I just need to know what to look for with winproc.
View 2 Replies
View Related
Feb 28, 2013
I want to change my system IP, subnet mask, host name etc. using win32 VC++.
I've tried AddIPAddress function but that's not persistent.
I want to change it that it should be change without rebooting system and should be there after restarting the system.
View 3 Replies
View Related
Apr 13, 2014
I am pretty new to windows programming, but i get around with small applications.
Now I want to create a window with 10 push buttons, and was just wondering if there is some smart way, maybe in a loop to create multiple buttons.
Also, on a very populated window, is there a way to maybe have the WM_CREATE commands stowed away in another cpp file? Just for readabilty.
View 13 Replies
View Related
May 15, 2014
I have a Win32 C++ application which works pretty well, but I don't like the GUI and I want to replace it with one designed graphically, a la Windows Forms. What is the best strategy to port my code? I tried creating a new Windows Forms C++ application and got pretty far with it, but was stymied when trying to call my unmanaged functions on a button press. If I can't use Forms to add a GUI without completely rewriting the program, what's my best bet?
View 14 Replies
View Related
Jul 9, 2013
I am trying to load an icon I created for my program. Relevant code is below:
Code:
//resource.h
#define IDR_MYMENU 103
#define IDR_MYICON 201
#define ID_HELP_NOTICE 40001
#define ID_HELP_ERROR 40002
#define ID_FILE_EXIT 40003
[Code] ....
For some reason, the icon fails to load. I ran a breakpoint at the line for the hIconSm and got this error for the variable:
Code: CXX0030: Error: expression cannot be evaluated
The icon image is in the source folder and was compiled via ImageMagick. Google is not giving me any info regarding the error and the icon combined.
View 2 Replies
View Related
Nov 30, 2013
I am using visual studio 2012 on windows 7. but, when I have compiled my programs and run them on an older pc to test out its functions, I receive an error saying that the program is not a "valid win32 application." I have even tested this with a very simple hello world console application, but the problem still remains. Where is the error coming from? is the application corrupted during transport? (upload to internet) or are programs compiled on win 7 incompatible with win xp
View 6 Replies
View Related
Feb 22, 2015
I am trying to get OpenGL to render inside of a Win32 api static control. I've gone through Nehe's tutorial [URL] on how to render to an entire window. I understand how to do that and I can do it, but I'm not totally sure how to get it to render inside of a static control(or any control). The idea is to have a gui built around an OpenGL view. how I could render inside a static or custom win32 control?
View 4 Replies
View Related
Aug 14, 2014
Is it possible to call VC++ routines using a Win32 DLL form fortran 77??
View 3 Replies
View Related
Sep 28, 2014
You place a breakpoint at one of locations within the message loop. But I want the breakpoint to trigger when I click on the application window, for example. But I can't, it went so fast so long as I switch from VS to the application program, the breakpoint is hitted again, then the application is frozen again. I don't know how to setup a conditional breakpoint.
View 3 Replies
View Related
Oct 31, 2014
Is it possible to show a console window in a Win32 DLL?
View 3 Replies
View Related
Jan 16, 2013
How can I call a dialog , which is present in a seperate Win32 resource DLL .
View 4 Replies
View Related
Mar 21, 2013
I can tons of information by calling DeviceIoControl (such as device ID, device description, whether it's connected or not) since I couldn't do it all with WMI. But I haven't figured out how to get from DeviceIoControl the info that a call to WMI's Win32_PortConnector gets. Are there any calls, directly to DeviceIoControl or something else that for a given device ID or device description would get the PortConnector information?
I would have used a combination of Win32_PortConnector and DeviceIoControl calls but the trouble with PortConnector is that it doesn't provide any information that would allow one to figure out which device ID it belongs to. Why do I need to do this? Because I'd like to get a combination of all the information the two methods provide for a given device such as a USB port, and all I'm getting from Win32_PortConnector is these scant few fields with no other clue:
string Caption;
string ConnectorPinout;
uint16 ConnectorType[];
string CreationClassName;
string Description;
string ExternalReferenceDesignator;
datetime InstallDate;
[Code] ....
View 1 Replies
View Related
Jan 25, 2015
I'm trying to have a button marked by the sqrt sign, '√'.
I wrote below code and typed that sign by holding down "alt" and typing 251 using numpad. But result is the question mark instead of sqrt mark!
My machine is Windows 7 x86 and IDE is visual studio 2012.
#include <GUI.h>
using namespace Graph_lib;
//---------------------------------
class Test : public Window {
public:
Test(Point, int, int, const string&);
[Code] .....
View 3 Replies
View Related
Jan 7, 2013
My setup is as follows:
There is function written C++, that must be compiled to DLL. This DLL is linked to some CAD (computer aded design) tool, that has special interface for it.
I want to add to this function some GUI (graphical user interface). So the creation of a window is necessary.
I've tried already with Win32, but without success.
The problem is that CreateWindow function requires application instance handle, that is provided by Windows itself when window is created in "normal conditions".
View 14 Replies
View Related
Sep 24, 2014
I know that if the structure doesn't fit into the stack, it needs to be put onto the heap. But what is maximum size of a win32 stack in usual case?
View 4 Replies
View Related
Feb 5, 2013
I want to print out unicode characters. But I want to do this using the key ids. Example:
int main()
{
std::cout << ('124'); //I would like this to output '|'
}
View 2 Replies
View Related
Feb 10, 2014
I'm writing a school assignment that writes/reads user input into and out of a binary file.
I've gotten the write part to work, but now I need to be able to read that file back in and display it as a string.
I think I should be using fread() and read my file into an array of int's right? But when I try printing out that array I get a whole bunch of numbers that don't match the hex code in my file.
How do I read in a binary file and print it out as a string?
View 4 Replies
View Related
Aug 10, 2013
I am writing a program to map keyboard and mouse to an xbox 360 controller with win32 and xinput. I have everything going fine but when im trying to control the mouse with the thumbsticks I get problems with the movement if my program has the focus it moves fine but when I put another window in focus the movement is over sensitive here is the code I am using
Code:
if(_controllerState.Gamepad.sThumbRX >= XINPUT_GAMEPAD_RIGHT_THUMB_DEADZONE) {
GetCursorPos(&mousepos);
profile->Buttons[6]->input.type = INPUT_MOUSE;
[Code] .....
I have tried everything to fix it.
View 1 Replies
View Related
Feb 25, 2014
For example if using FindFirstFile(...) it assumes your passing LCPWSTR and not LPCSTR.
I know I can use FindFirstFileA or FindFirstFileW so what is point of default if always UNICODE.
Which brings to my second question. If I say
FindFirstFile("C:", &fdat);
I get error cannot convert parameter 1 from 'const char [7]' to 'LPCWSTR'
I could say WCHAR fName = "C:"; and pass this variable instead. However is there a way to cast "C:" on-the-fly to LPCWSTR, I tried,
FindFirstFile((LCPWSTR)"C:", &fdat);
But it outputs a stream of LONGs to the console instead of filenames.
View 5 Replies
View Related
Sep 13, 2013
I have a problem when i try to save unicode to a .txt file.
I need to store in a file names that will have letters like "ăĂâÂșȘțȚîÎ"
wchar_t name []=L"ăĂâÂșȘțȚîÎ";
FILE* fang;
fang= _wfopen( L"test.txt",L"wt+,ccs=UNICODE");
fwprintf (fang, L"%ls ",name);
When i open my text file i get this: ??âÂ????îÎ
if i use
fang=fopen("test.txt","a");
I get the same result
and for
fang=fopen("ang.txt","a,css=UNICODE");
I get a runtime eroror "invalid file open mode"
View 2 Replies
View Related
Feb 28, 2012
I need to read Unicode characters from a file. The only thing I need to do from them is to extract their Unicode number.
For example if file has u I need to extract its corresponding Unicode number.
View 3 Replies
View Related