|
Hi Sauro,
wsprintf (which resolves into wsprintfA and wsprintfW) is a version of either sprintf or swprintf implemented by USER (IIRC, might be KERNEL). swprintf is the unicode sprintf like function - nice of them to change a couple of letters like that!
To add to the confusion wsprintf can't handle any floating point formats the way sprintf and swprintf can and can only handle 1k of characters.
Cheers,
Ash
|
|
|
|
|
Sauro Viti wrote: wsprintf which is an unicode function
1. Not true, it works on either and is actually defined to wsprintfA or wsprintfW depending on the setting of UNICODE .
2. see 1, but also the reason for the crash is that lpszstr is not initialised to point to anything.
3. wsprintf_s does not exist. As far as I recall the wxxx functions were created for windows programs that did not include stdio.h .
It's time for a new signature.
|
|
|
|
|
LPSTR lpszstr;
this is a pointer, not a string. and it doesn't point anywhere (you haven't initialized it). you need to allocate some memory for a string, and then use that in your wsprintf.
you need something like this:
TCHAR str[100];
wsprintf(str,"%s","sdfsdfsd fsdfsdfsdf");
also, it might be good to read about the differences between pointers and arrays[^].
|
|
|
|
|
if you didn't allocate enough memory for lpszstr to hold the string you copy to it, definitly access violation will happen, and as wsprintf() doesn't throw any exception, you can't expect to catch it
|
|
|
|
|
最近在写个驱动安装程序,里面用到一些内核函数比如UpdateDriverforPlugAndDevice(),用的vs2008,在32位操作系统下工作正常,win32的程序可以在x64下运行,但是在64位下就会出错,比如UpdateDriverforPlugAndDevice(),我用GetLastError(),看到出错。后来我在64位系统下装了vs2008,编译出x64程序,一切运行正常,但是这个程序无法在win32下运行。问题是解决了,但是我现在用维护两个版本32下一个,64位一个;不知道大家有什么好方法,只要运行一个版本。
|
|
|
|
|
Sorry, but we cannot understand this, can you please have your question translated into English?
It's time for a new signature.
|
|
|
|
|
This is an english only website, please translate your question: we are not able to understand it
|
|
|
|
|
|
xjh_sz wrote: For example UpdateDriverforPlugAndDevice (), I used GetLastError (), see the error.
And what is that error?
xjh_sz wrote: The problem is solved, but I now maintain two versions with the next 32, 64 a; do not know what a good way, just run a version. Not sure I understand this. Are you wanting one set of source code, but two separate exe files?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Dave,
It is nice of you to translate OP question and try to give some clue. Shouldn't you tranlated your answer to chinease though
|
|
|
|
|
Yusuf wrote: Shouldn't you tranlated your answer to chinease though
不,我不会说中文。
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
You would get more help if you describe your problems in English.
以前你也用中文在这里叫过吧?鬼佬们不懂中文,白瞎了~~
个人理解,仅供参考:
win32程序在win64上面是通过wow64工作的,被。64位程隔离在一个独立的环境里面序和32位程序在用户层不可互访。因此没有办法只用一个程序在64位和32位间无缝转换。即64环境中必须用64的程序才能安装64位的驱动,32位环境中只能用32位程序安装驱动。
不过完全可以做到在源代码层面统一。
modified on Wednesday, July 21, 2010 9:19 AM
|
|
|
|
|
xjh_sz wrote:
I recently created a driver installation program, which uses a number of core functions such as UpdateDriverforPlugAndDevices(), using vs2008, in 32-bit operating system everything is working properly. But win32 program can run in x64, but under x64 it does not work. For example UpdateDriverForPlugandPlayDevices() raises an error, I used GetLastError (), and I see an error code. Later I was using a 64-bit system with vs2008 and compiled the x64 program, everything works fine, but the program can not run in win32. The problem is now solved, but I now maintain two versions of the installer 32 and 64; I do not know what a better way, I just run a seperate version of the executable.
Hi xjh_sz,
I believe that you are doing the correct thing by creating two separate installers for 32 and 64 bit. UpdateDriverForPlugAndPlayDevices does not support WOW64. You might be able to get your 32 bit installer to work by calling Wow64EnableWow64FsRedirection[^] but I honestly don't know for sure.
Some additional documentation:
Driver Installation for 32-bit and 64-bit Platforms[^]
Best Wishes,
-David Delaune
|
|
|
|
|
First,thanks for your replies.I am sorry to you because I asked question in chinese.
My question is as fllows.
I recently created a driver installation program, which uses a number of core functions such as UpdateDriverforPlugAndDevice(), using vs2008, in 32-bit operating system everything is working properly. But win32 program can run in x64, but under x64 it does not work. For example UpdateDriverForPlugandPlayDevices() raises an error, I used GetLastError (), and I see an error code. Later I was using a 64-bit system with vs2008 and compiled the x64 program, everything works fine, but the program can not run in win32. The problem is now solved, but I now maintain two versions of the installer 32 and 64; I do not know what a better way, I just run a seperate version of the executable.
|
|
|
|
|
Hi i am trying to delete all the columns in the clistctrl in MFC.But some columns are not getting deleted.Can anyone help me in this regard.
Kishore Kumar
|
|
|
|
|
How did you try to delete the columns?
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
I suspect you're giving the column index to the DeleteColumn function.
Instead always use the index of 0.
This is from the documentation of DeleteColumn .
int nColumnCount = m_myListCtrl.GetHeaderCtrl()->GetItemCount();
for (int i=0; i < nColumnCount; i++)
{
m_myListCtrl.DeleteColumn(0);
}
|
|
|
|
|
In addition to this, one also might want to use m_myListCtrl.SetRedraw() around those list operations to improve performance and reduce animation effects. Maybe even using a RAII like implementation for it.
|
|
|
|
|
Hello,
as most of you know, you can fill a Listbox with a complete directory list by Sending a message LB_DIR. This works fine, for example I create a CListBox Control like this, and fill the contents with a directory list:
CListBox m_List1;
...
m_List.SendMessage(LB_DIR,DDL_READWRITE ,(long)(const char*)(CString("C:\\temp\\*.*").GetBuffer(0)));
(Alternatively, you can use
m_List.Dir(DDL_READWRITE, "C:\\temp\\*.*");
which leads to exactly the same result)
The problem I have is the following: if a file in my directory has not set any of the following bits:
- "File is ready for archiving"
- "For fast searching, allow Indexing service to index this file"
it won't appear in my list. In order to do this, use Windows explorer, right-click on a file, select properties, look at Attributes and click the button "Advanced", and remove the upper two checkboxes.
No matter what attributes I set, when these two checkboxes are not set, the file will not be listed.
Can you please try to reproduce this? I think this is a severe bug that Microsoft should fix, or am I doing something completely wrong? How can I overcome this behaviour? Is there any known fix to this issue?
|
|
|
|
|
m_list.Dir(DDL_READWRITE, "C:\\temp\\*.*");
tried and works fine for me..
|
|
|
|
|
Works the same way here too, if none of those attributtes are set then the files do not appear in the listbox, don't know what causes this and how you can fix it (aside of forgetting about it and writing your own code to fill the list using FindFirstFile[^], FindNextFile[^] and FindClose[^] or somesuch)
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
modified on Wednesday, July 21, 2010 5:36 AM
|
|
|
|
|
I have run some tests on this and it appears that the removal of the "For fast searching, allow Indexing service to index this file" bit is the problem. If this bit is set then the file appears in my list, even if the Archive bit is not set. This may have something to do with the way the bit is interpreted as a 'not' option, as described by dir /? .
Using FindFirstFile() / FindNextFile() I get all the files, including the one with indexing not set (attribute 0x2000), so it definitely looks like a Microsoft bug.
It's time for a new signature.
modified on Wednesday, July 21, 2010 7:52 AM
|
|
|
|
|
Thanks alot, as for the other two persons who were not able to reproduce this behaviour: which OS do you use? I have only XP Pro for testing, and I can reproduce it on every XP machine available in my office.
|
|
|
|
|
I'm on Windows 7 Home Premium, it looks like this has been around for some time.
It's time for a new signature.
|
|
|
|
|
Thanks, so it's obviously not fixed in Win7, does anybody know how to report this directly to Microsoft? Any chance they will do anything to fix this?
|
|
|
|