|
Check the response in SysAdmin/OS section
Venet.
--------
Black holes are where God divided by zero.(Steven Wright)
|
|
|
|
|
Hi,
I have Win32-application project in VC6, it contains no resource.
Hmm, can I use a resource and those functions: GetModuleHandle(), FindResource(), LoadResource() as I used them in a MFC application? What do I need to do to add a resource to a Win32 project?
Thx for help, Moak
PS: What kind of resource management do you use on multiplatform environments (e.g. Windows & Linux)? I know the above mentioned resource thingie is not portable (but very handy to use). On other platforms I ususally have a small tool that creates static BYTE s_arrays[] from the data and compile/link the resulting c-files/objects to the executable.
|
|
|
|
|
Hi again, I mentioned my win32 based executable also has no icon and version information (when showed in the explorer). Can I add this too?
|
|
|
|
|
BIG SORRY... I didn't found it via Google, but with Google Usenet archive:
Here is a pretty good explanation I found - and works great:
Newsgroups:comp.os.ms-windows.programmer.win32
Date:2001-10-24 10:07:07 PST
Insert->Resource->Icon->Import... (browse for your icon)
Use Alt+Enter to invoke "Icon Properties" dialog.
Assign an ID to your icon (e.g. IDI_APPICON).
Save(Ctrl+S) as MyApp.rc
Project->Add to project->Files...->MyApp.rc
Build
From that point on, the icon will appear in Explorer.
To assign the icon to the window also, add into your
WinMain:
#include "Resource.h"
...
WC.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APPICON))
That's it, more or less.
HTH
Jugoslav
|
|
|
|
|
Hi,
I know it is a VC++ forum, but i really need help!!! Let's see my code first:
*****************************************************************************
void operation(int[], char[]);
void waitprocess(int);
void main(void)
{
int i, j;
static char buffer[BUFSIZE+10], X_value[5], message[BUFSIZE];
int f_des[2];
if (pipe(f_des) == -1)
{
perror("Pipe");
exit(2);
}
if (fork()==0)
{
}
else
{
for (j=1; j<=5; j++)
{
if (fork()==0)
{
static char temp[BUFSIZE];
sprintf(temp, "Thread %d", getpid());
operation(f_des, temp);
}
}
while (X>0)
{
close(f_des[1]);
if (read(f_des[0], message, BUFSIZE) != -1)
{
sprintf(buffer, " - X = %d \n", X);
strcat(message, buffer);
write(1, message, sizeof(message));
waitprocess(getpid());
X--;
}
else
{
printf("error");
}
}
}
}
****************************************************************************
I have to create 5 "threads" but using fork() because i have to use pipe() to communicate with "server". This program is doing that 5 "threads" are trying to decrement the global X until X=0. I use pipe as a mechanisam to protect this "critical section". I don't know whether i did it right or wrong. Please help me to check!!!
Also, I found that the output looks strange. The output is always in a pattern. For example, the output looks liked:
Thread 1001 - X = 20
Thread 1003 - X = 19
Thread 1002 - X = 18
Thread 1005 - X = 17
Thread 1004 - X = 16
Thread 1001 - X = 15
Thread 1003 - X = 14
Thread 1002 - X = 13
Thread 1005 - X = 12
Thread 1004 - X = 11
*
*
*
You can see the sequence is 1,3,2,5,4,1,3,2,5,4...etc. I think the output should be in random sequence. Why it's happened???
Thanks!!!!!
|
|
|
|
|
Yes, this IS a VC++ forum. The odds of you finding an answer here are probably slim, but I'll tell you right away, they won't increase from you asking over & over. You'll just annoy people, and possibly miss out on a reply.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|
ChiYung wrote:
but i really need help!!!
If you post your question on the comp.lang.c.moderated newsgroup, you will get an answer to your question. It is the one I frequent when answering Unix questions. If you don't have a news reader you can go to groups.google.com
Hope that helps.
After a poor performance in London in 1899, Steinitz went insane and died a year later on August 12, 1900 at Wards Island, N.Y.
|
|
|
|
|
I thought comp.lang.c.moderated was dead ? I use comp.lang.c++ a bit, but I thought the moderated one was closing down...
comp.lang.c++ are pretty tough on off topic questions if they relate to Windows, but pretty easy on Unix off topic questions in my experience.
Christian
I am completely intolerant of stupidity. Stupidity is, of course, anything that doesn't conform to my way of thinking. - Jamie Hale - 29/05/2002
Half the reason people switch away from VB is to find out what actually goes on.. and then like me they find out that they weren't quite as good as they thought - they've been nannied. - Alex, 13 June 2002
|
|
|
|
|
Christian Graus wrote:
comp.lang.c++ are pretty tough on off topic questions if they relate to Windows, but pretty easy on Unix off topic questions in my experience.
Are you trying to lead him to trouble? Look at the what the moderators say about questions pertaining to C. http://www.gotw.ca/modguide.htm
After a poor performance in London in 1899, Steinitz went insane and died a year later on August 12, 1900 at Wards Island, N.Y.
|
|
|
|
|
Why are you expecting to see random output? I don't see any randomness-generating functions in your code. Try adding a random delay somewhere and see if that changes the output.
|
|
|
|
|
I'm using Intel's C++ compiler, version 6, as a plug-in compiler in Visual Studio 6, with the latest MS Platform SDK. When I use the Qwp_ipo (multi-file interprocedural optimizations) compiler switch, I get the following error at link time:
IPO: performing multi-file optimizations
Error unresolved : _main
Referenced in libc.lib(crt0.obj)
I do NOT have _ATL_MIN_CRT defined. Additionally, this problem never occurred with the MS compiler or version 5 of Intel's compiler.
If I link dynamically with /MD instead of with /ML, it builds fine, but that requires the end user to have one Intel's math library dll which I can't redistribute under the evaluation license I have.
I don't even know how to start debugging this...
|
|
|
|
|
Anonymous wrote:
If I link dynamically with /MD instead of with /ML, it builds fine, but that requires the end user to have one Intel's math library dll which I can't redistribute under the evaluation license I have.
But you are allowed to distribute a compiled binary??? Methinksnot.
Besides, this is the wrong place for your question. Please contact Intel or try some Intel newsgroups/forums.
|
|
|
|
|
>> But you are allowed to distribute a compiled binary??? Methinksnot.
There is no statement to that effect in the license agreement. Anyway, thanks for the reply.
|
|
|
|
|
When it comes to the "DeviceIoControl (hCD, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &dgCDROM, sizeof(dgCDROM), &dwNotUsed, NULL)" function, the GetLastError returns 1, which is incorrect function, what is that?
code:
HANDLE hCD, hFile;
DWORD dwNotUsed;
hFile = CreateFile ("sector.dat",
GENERIC_WRITE, 0, NULL, CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL, NULL);
hCD = CreateFile ("\\\\.\\D:", GENERIC_READ,
FILE_SHARE_READ|FILE_SHARE_WRITE,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
NULL);
if (hCD != INVALID_HANDLE_VALUE)
{
DISK_GEOMETRY dgCDROM;
PREVENT_MEDIA_REMOVAL pmrLockCDROM;
pmrLockCDROM.PreventMediaRemoval = TRUE;
DeviceIoControl (hCD, IOCTL_DISK_MEDIA_REMOVAL,
&pmrLockCDROM, sizeof(pmrLockCDROM), NULL,
0, &dwNotUsed, NULL);
if (DeviceIoControl (hCD, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &dgCDROM, sizeof(dgCDROM), &dwNotUsed, NULL))
{
LPBYTE lpSector;
DWORD dwSize = 2 * dgCDROM.BytesPerSector;
lpSector = (LPBYTE)VirtualAlloc (NULL, dwSize, MEM_COMMIT|MEM_RESERVE, PAGE_READWRITE);
SetFilePointer (hCD, dgCDROM.BytesPerSector * 16,
NULL, FILE_BEGIN);
if (ReadFile (hCD, lpSector, dwSize, &dwNotUsed, NULL))
WriteFile (hFile, lpSector, dwSize, &dwNotUsed, NULL);
VirtualFree (lpSector, 0, MEM_RELEASE);
}
pmrLockCDROM.PreventMediaRemoval = FALSE;
DeviceIoControl (hCD, IOCTL_DISK_MEDIA_REMOVAL,
&pmrLockCDROM, sizeof(pmrLockCDROM), NULL,
0, &dwNotUsed, NULL);
CloseHandle (hCD);
CloseHandle (hFile);
}
r, true);
// Unlock the disc in the CD-ROM drive.
pmrLockCDROM.PreventMediaRemoval = FALSE;
DeviceIoControl (hCD, IOCTL_DISK_MEDIA_REMOVAL,
&pmrLockCDROM, sizeof(pmrLockCDROM), NULL,
0, &dwNotUsed, NULL);
CloseHandle (hCD);
CloseHandle (hFile);
}
|
|
|
|
|
Isn't it that you can only use IOCTL_DISK_GET_DRIVE_GEOMETRY on a physical device? You only have a handle to the mounted filesystem.
|
|
|
|
|
ok, this is my code:
char *s = (char *)malloc(1024);
DWORD dwBytesRead;
HANDLE hFile;
hFile = CreateFile("\\\\.\\D:", GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
ReadFile(hFile, s, 1024, &dwBytesRead, NULL);
CloseHandle(hFile);
free(s);
D is my CD drive, but when i do this, the ReadFile function returns 1 indicating the operation went succesful. bu the dwBytesRead is 0 and the buffer hasn't been filled. however if i change the "\\\\.\\D:" to ("\\\\.\\C:", then it works fine, anyone know what's wrong?
thanks in advance
|
|
|
|
|
I don't have the answer to your question but I don't think you want FILE_SHARE_WRITE on a read-only device.
|
|
|
|
|
I know, but it can't hurt, can it?
|
|
|
|
|
sonork: 100:18407
You yard yellow years yieldingly; you yanked your yearning yoke.
-Jeremy Falcon
|
|
|
|
|
Here's some code to help you out.
void CCDReadDlg::ReadCD()
{
DWORD dwSize = 2048;
DWORD dwBytesRead;
LPBYTE lpBuffer;
HANDLE hFile;
hFile = CreateFile("\\\\.\\F:", GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (hFile != INVALID_HANDLE_VALUE)
{
lpBuffer =(unsigned char*) VirtualAlloc (NULL, dwSize,
MEM_COMMIT|MEM_RESERVE,
PAGE_READWRITE);
//In CDFS(i.e.ISO9660 format) sector size is 2048.
//the first 16 sectors are always filled with 0's
//To get something meaningful first skip to 16th sector and then read
//course the propah way is to first use DeviceIoControl calls
//to lock the media and finally unlock it after reading... .
SetFilePointer (hFile, dwSize*16,
NULL, FILE_BEGIN);
if (ReadFile (hFile, lpBuffer, dwSize, &dwBytesRead, NULL))
{
//you buffer should have a volume descriptor
//to begin with
//do something
}
VirtualFree (lpBuffer, 0, MEM_RELEASE);
}
CloseHandle(hFile);
}
sonork: 100:18407
You yard yellow years yieldingly; you yanked your yearning yoke.
-Jeremy Falcon
|
|
|
|
|
dwBytesRead is 0 and lpBuffer is empty. But the ReadFile function returns 1 so there shouldn't be anything wrong... strange
|
|
|
|
|
dwBytesRead is 2048 for me(with media present in CDROM ofcourse) i.e. 1 sector(just what I want) and lpBuffer contains the CDROM volume description as expected.
You yard yellow years yieldingly; you yanked your yearning yoke.-Jeremy Falcon-CPite.
Amit Dey
sonork: 100:18407
msn: visualcdev
|
|
|
|
|
Is your CDROM drive setup correctly? Do you have any other cdfs drivers like Adaptec DirectCD on your system? course, you are trying this code on Win2K/NT...right?
hmmm....
You yard yellow years yieldingly; you yanked your yearning yoke.-Jeremy Falcon-CPite.
Amit Dey
sonork: 100:18407
msn: visualcdev
|
|
|
|
|
HI
i want to have a toolbar on desktop, but CreateToolbarEx()
needs a window handle as a parent. I have passed the desktop handle by calling GetDesktopWindow but it doesn't work. Is there any solution to the problem.
|
|
|
|
|
You'd want to use an appbar. Please lookup codeproject for an article and code on appbars.
sonork: 100:18407
You yard yellow years yieldingly; you yanked your yearning yoke.
-Jeremy Falcon
|
|
|
|
|