473,703 Members | 2,356 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

CreateFile returns invalid handle value when I use wcscpy in my source... ...need a help.

Hello

I got an unusual problem and I don't know how to solve it out.

I need to get success with the handle variable hFile. It's not problem
'til I use wcscpy(...). I mean, when I take out those two double-
slashes the source is not working and the func CreateFile returns
0xFFFFFF to that variable. It seems to me that it has some context
with using wcscpy? But why?

void SaveWorkerFile( void)
{
TCHAR szSoubor[MAX_PATH];//

int StrLength;
LPTSTR lpBuffer;
WCHAR temppp[200];
WCHAR UnicodeIdr[10];
HANDLE hFile;

UnicodeIdr[0] = 0xFEFF; UnicodeIdr[1] = 0x0000;
// wcscpy(temppp, UnicodeIdr);
// wcscat(temppp, TEXT("MK0000000 0 01/01/07 REZIEROTEC
PocetHodin Popis \r\n"));

StrLength = lstrlen(temppp) +10;

lpBuffer = (LPTSTR)HeapAll oc(GetProcessHe ap(), 0, StrLength);
GetWindowText(h WndDatabaseWind ow, lpBuffer, StrLength);
wcscpy(lpBuffer , temppp);

DWORD dwZapsano;
lstrcpy(szSoubo r, TEXT("C:\\RCOMM ISIONS\\mkatab. txt"));

hFile = CreateFile(szSo ubor, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
0, NULL);
if(hFile == INVALID_HANDLE_ VALUE) return;
if(!WriteFile(h File, lpBuffer, StrLength-1, &dwZapsano, NULL))
MessageBox(g_hW nd, TEXT("Error in writing file process."),
TEXT("Error"), MB_ICONERROR);
CloseHandle(hFi le);
HeapFree(GetPro cessHeap(), 0, lpBuffer);

return;
}

Any help will be apprecciated.

Have a nice day:-)

Feb 27 '07 #1
6 5654
MIUSS wrote:
Hello

I got an unusual problem and I don't know how to solve it out.

I need to get success with the handle variable hFile. It's not problem
'til I use wcscpy(...). I mean, when I take out those two double-
slashes the source is not working and the func CreateFile returns
0xFFFFFF to that variable. It seems to me that it has some context
with using wcscpy? But why?

void SaveWorkerFile( void)
{
TCHAR szSoubor[MAX_PATH];//
Getting repetitive tonight...

This looks horribly like widows code, so you'd better post to windows
development group.

--
Ian Collins.
Feb 27 '07 #2
On 26 Feb 2007 23:13:36 -0800 in comp.lang.c++, "MIUSS" <mi***@seznam.c zwrote,
>I need to get success with the handle variable hFile. It's not problem
'til I use wcscpy(...). I mean, when I take out those two double-
slashes the source is not working and the func CreateFile returns
Thee is no wcscpy() nor CreateFile() in the standard C++ library.

See the welcome message posted twice per week in comp.lang.c++ under the subject "Welcome to comp.lang.c++! Read this first." or available at
http://www.slack.net/~shiva/welcome.txt

Feb 27 '07 #3
Hello everyone,

I've found the fault and already have solved this problem. I used too
much long string in func wcscpy in TEXT("...") which resulted in
invalid handle value then. Thank you for your willigness and have a
nice day:-)

Ian Collins napsal:
MIUSS wrote:
Hello

I got an unusual problem and I don't know how to solve it out.

I need to get success with the handle variable hFile. It's not problem
'til I use wcscpy(...). I mean, when I take out those two double-
slashes the source is not working and the func CreateFile returns
0xFFFFFF to that variable. It seems to me that it has some context
with using wcscpy? But why?

void SaveWorkerFile( void)
{
TCHAR szSoubor[MAX_PATH];//
Getting repetitive tonight...

This looks horribly like widows code, so you'd better post to windows
development group.

--
Ian Collins.
Feb 27 '07 #4
Ian Collins wrote:

Getting repetitive tonight...

This looks horribly like widows code, so you'd better post to windows
development group.
Those poor widows.


Brian
Feb 27 '07 #5
Later I get to know that it isn't neither because of long string in
TEXT(...)... So I don't know where the fault come from. There must be
some stupid bug. I've gave up and I've had to copy my older code where
I hadn't any problem with invalid handle value... I've copied it to my
new project and it works fine.. It's almost the same I only use TCHAR
instead of WCHAR and lstrcpy instead of wcscpy...

MIUSS napsal:
Hello everyone,

I've found the fault and already have solved this problem. I used too
much long string in func wcscpy in TEXT("...") which resulted in
invalid handle value then. Thank you for your willigness and have a
nice day:-)

Ian Collins napsal:
MIUSS wrote:
Hello
>
I got an unusual problem and I don't know how to solve it out.
>
I need to get success with the handle variable hFile. It's not problem
'til I use wcscpy(...). I mean, when I take out those two double-
slashes the source is not working and the func CreateFile returns
0xFFFFFF to that variable. It seems to me that it has some context
with using wcscpy? But why?
>
void SaveWorkerFile( void)
{
TCHAR szSoubor[MAX_PATH];//
>
Getting repetitive tonight...

This looks horribly like widows code, so you'd better post to windows
development group.

--
Ian Collins.
Feb 28 '07 #6
David Harmon wrote:
On 26 Feb 2007 23:13:36 -0800 in comp.lang.c++, "MIUSS" <mi***@seznam.c zwrote,
>>I need to get success with the handle variable hFile. It's not problem
'til I use wcscpy(...). I mean, when I take out those two double-
slashes the source is not working and the func CreateFile returns


Thee is no wcscpy() nor CreateFile() in the standard C++ library.
wcscpy is part of the standard C library, and therefore part of the
standard C++ library too.

john
Feb 28 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
14630
by: Meg | last post by:
Hi All, I am having a problem with paging in datagrid and need some idea as to how to handle the problem 1. the datagrid is first filled with a select * all 2. the datgrid shows 10 pages 12345678910 3. the first page shows 10 records 4. if do a keyword search on the full dataset the selected records are returned...I can repeat this many times while my page index is set to page 1.
2
2306
by: vasanth kumar | last post by:
Hi, I have a problem in dealing with the return value of the SQL command. I know how to do, when SQL command returns Recordsets. But in my case it returns a single value. The following code fails when "objRst.open strQ" is executed. Can somebody suggest me how to overcome this problem. Any Help is appreciated. Thanks in advance, Vasanth ----------------------- Set objConnect = Server.CreateObject("ADODB.Connection") objConnect.Open...
0
2081
by: nek | last post by:
Would anyone have any ideas or come across the 'invalid handle' problem? Even after setting diaglevel=4, I could not get much out of the db2diag.log to diagnose the problem. The only thing I could relate to this is DB2 appears to hang when this happens. Here is sample entry from db2diag.log: 2004-01-23-12.40.02.880000 Instance:DB2 Node:000
0
1079
by: Kelvin | last post by:
Hi all, I have to 2 radiobuttons to control 2 datagrid summay and detail representively. when I click detail radionbutton, In detail report 10 pages records. In the summary report just only 1 page record. When I click summary radiobutton, I select 3rd pages it display the following error. "System.Web.HttpException: Invalid CurrentPageIndex value. It must be >= 0 and < the PageCount. "
2
5733
by: Schorschi | last post by:
Can't seemd to get ReadFile API to work! Returns invalid handle error? =========================================================================== Ok, the visual basic gurus, help! The following is a diskette class (vb .net) that works find, in that I can validate a diskette is mounted, dismount it, lock it, unlock it, get diskette geometry, etc., all with a valid handle from CreateFile API! I can even position the file pointer,...
3
3512
by: Terry Olsen | last post by:
I have a string that is approximately 600 characters. I need to divide up the string into 400 character chunks. I'm having trouble with using LastIndexOf. The following code returns a value of 594. value=msg(i).LastIndexOf(" "c) The following code returns a value of -1 value=msg(i).LastIndexOf(" "c,1)
13
1323
by: =?Utf-8?B?TWFyaw==?= | last post by:
Need help with a variable... This variable is used to keep track of permissions and can contain 1,2,4,8,16,32,64,128 Or it can contain a sum of one more of the above values. For example, if the variable has a value of 255, then it has all ove the above values added together. I need help in figuring out the permissions, when for example the variable contains 2 or more values added together. If I can break the larger number down to...
1
1849
by: Raymond Du | last post by:
Hi guys, I need help with an error, the message: Invalid postback or callback argument. I never saw this error happened to me, not on IE nor FF, but Log4Net I used on production server logs about 100 exceptions on one specific page every day. Here is the Stack trace: Method Name:
2
2387
by: jagadeeshaHS | last post by:
Hi, getting invalid atoi value for the below program, help me resolving this issue. #include <stdlib.h> #include <stdio.h> #include <math.h> int main () { char *num = "222211113333"; int atNum ;
0
8762
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8674
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9265
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9125
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7878
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6598
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5923
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3127
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2463
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.