|
Examples of IPC include:
Sockets
Clipboard
COM
Pipes
Data Copy
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
I've had to do this many times, and have found the easiest way is to use (global) named pipes. The process that does the word opens the pipe server, and just waits for a message to come through. Any processes that need an action to be preformed then open a client pipe, and sends all the data through. This system even allows for duplex messaging, so the server can send a response and/or the results of the processing back to the caller if required.
The Microsoft Devcenter explains it all pretty well, with examples, here[^].
|
|
|
|
|
Hi
I have been getting an internal compiler for a "for(;;) statement I simplified it as much as possible till it looks like this
for (; i >= 0; i--, j--)
and I still get the error the code compiles in debug mode
thanks
|
|
|
|
|
Please show a few lines of code either side, plus the exact code that produces the error, and the exact and complete message.
|
|
|
|
|
Jochen was right on qeue I put a pragma for optimize off
Around the code and it was able to build
|
|
|
|
|
When it compiles in debug builds, the compiler gets stuck during optimisation.
See also the MSDN Fatal Error C1001[^]. It suggests to disable optimisation for the function or rewrite the code.
With older VS versions I had such errors a few times and solved them always by re-ordering some code lines. As you already noticed, reducing (simplifying) the code may not help. Instead it might help to add code lines.
|
|
|
|
|
Thanks so much that did it I put pragma for optimize off
|
|
|
|
|
TCHAR userName[100];//user input buffer
hwndedit=GetDlgItem(hwnd,IDC_UNICALPTUME_SUBJECT_TBOX);//gets edit control's handle
userName[100]=(TCHAR) SendMessage(hwndedit,WM_GETTEXT,(WPARAM)sizeof(userName)/sizeof(userName[0]),(LPARAM)userName);//Sent message
return (INT_PTR)TRUE;
case IDOK://checks if buffer is empty or not when the user clicks OK on the dialog
if(userName!=NULL)
EndDialog(hwnd,TRUE);
return (INT_PTR)TRUE;
l also tried GetWindowText(hwnd,userName,sizeof(userName)/sizeof(userName[0]))
still it doesn't work. Please can someone me guide me on getting user input and checking if the buffer is empty or not.
Thanks everyone.
modified 18-Jan-16 17:11pm.
|
|
|
|
|
userName[100]=(TCHAR) SendMessage(hwndedit,WM_GETTEXT,(WPARAM)sizeof(userName)/sizeof(userName[0]),(LPARAM)userName);
You are casting your return value to a single character and storing it in one character position beyond the end of your buffer. You should just use GetWindowText like this:
int nSize = GetWindowText(hwndedit, userName, _countof(userName));
See GetWindowText function (Windows)[^] and _countof Macro[^].
|
|
|
|
|
|
The default context menu (in explorer and open file dialogs) looks like the image below:
The selected menu item has a dark gray background, and I don't like it. It can't be replaced by the theme.
I want to restore its style to Windows 8/8.1 style, like this(Windows 10 earlier insider builds):
I have programmed a COM dll and attach it to the explorer, it's able to retrieve the handle of the context menu, but I discovered that none of those menu items have the "MF_OWNERDRAWN" flag, they just have "MF_STRING" flag.
So things start to getting wired, perhaps they are not normal owner drawn menus?
My question is how does the explorer render its context menu? And are there anyway to customize its style? eg using hook?
|
|
|
|
|
I've been recently asked in an interview to write down a function that takes a char and returns void, and using this char the function would call between 5 different functions,
Beside I have to write this function in three different ways.
I figured out two, but failed to come with the third.
My two functions were : 1- using switch on the coming argument
2 - using if else statements
,, can some 1 deduce the third , this is bugging me.
|
|
|
|
|
Here's an idea:
Use the char as an array index for an array of function pointers.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
alright I like this one
|
|
|
|
|
Hi,
I need to check from a dll that If a particular driver is already installed or not. Also i need to un-install it.
I have INF file of the driver.
Please let me know how can i do this using C/C++.
Thanks
Prasanth
|
|
|
|
|
|
Am creating application and l need to fill a combo box list. However, l was able to do all and is working but whenever l filling the last combobox, l get an exception as below.
First-chance exception at 0x7789dba9 in Unical PTUME.exe: 0xC0000005: Access violation reading location 0x00000001.
Unhandled exception at 0x7789dba9 in Unical PTUME.exe: 0xC000041D: An unhandled exception was encountered during a user callback.
What does it mean and how can l correct it?
code snippet below:
case WM_CREATE:
DialogBox(((LPCREATESTRUCT)lParam)->hInstance, MAKEINTRESOURCE(IDD_CHOICEBOX),hWnd,choicedlg);
return 0;
INT_PTR CALLBACK choicedlg(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){
int i=0; static int firsttime=1; PWSTR input=NULL;
switch(message)
{
case WM_INITDIALOG:
for(i=0; i<=sizeof(Choice)/sizeof(Choice[0]); i++){
SendDlgItemMessage(hwnd,IDC_UNICALPTUME_FACULTY,CB_ADDSTRING,0,(LPARAM)Choice[i]);
}
for(i=0; i<=sizeof(Course)/sizeof(Course[0]); i++){
SendDlgItemMessage(hwnd,IDC_UNICALPTUME_SUBJECT1,CB_ADDSTRING,0,(LPARAM)Course[i]);
SendDlgItemMessage(hwnd,IDC_UNICALPTUME_SUBJECT2,CB_ADDSTRING,0,(LPARAM)Course[i]);
SendDlgItemMessage(hwnd,IDC_UNICALPTUME_SUBJECT3,CB_ADDSTRING,0,(LPARAM)Course[i]);
SendDlgItemMessage(hwnd,IDC_UNICALPTUME_SUBJECT4,CB_ADDSTRING,0,(LPARAM)Course[i]);
SendDlgItemMessage(hwnd,IDC_UNICALPTUME_SUBJECT5,CB_ADDSTRING,0,(LPARAM)Course[i]);
SendDlgItemMessage(hwnd,IDC_UNICALPTUME_SUBJECT6,CB_ADDSTRING,0,(LPARAM)Course[i]);
}
for(i=0; i<=sizeof(Year)/sizeof(Year[0]); i++){
SendDlgItemMessage(hwnd,IDC_UNICALPTUME_YEAR1,CB_ADDSTRING,0,(LPARAM)Year[i]);
SendDlgItemMessage(hwnd,IDC_UNICALPTUME_YEAR2,CB_ADDSTRING,0,(LPARAM)Year[i]);
SendDlgItemMessage(hwnd,IDC_UNICALPTUME_YEAR3,CB_ADDSTRING,0,(LPARAM)Year[i]);
SendDlgItemMessage(hwnd,IDC_UNICALPTUME_YEAR4,CB_ADDSTRING,0,(LPARAM)Year[i]);
SendDlgItemMessage(hwnd,IDC_UNICALPTUME_YEAR5,CB_ADDSTRING,0,(LPARAM)Year[i]);
SendDlgItemMessage(hwnd,IDC_UNICALPTUME_YEAR6,CB_ADDSTRING,0,(LPARAM)Year[i]);
}
However, if l add the code below, l always get error message as above.
for(i=0; i<=sizeof(Time)/sizeof(Time[0]); i++){
SendDlgItemMessage(hwnd,IDC_UNICALPTUME_TIME,CB_ADDSTRING,0,(LPARAM)Time[i]);
}
modified 18-Jan-16 17:12pm.
|
|
|
|
|
What is the value of Time[i] when the code runs?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
All your for loops are iterating from 0 to (including) sizeof(array)/sizeof(array[0]) :
for(i=0; i<=sizeof(Time)/sizeof(Time[0]); i++)
So they will access one item behind the array size with the last iteration because the max. allowed index is the number of items minus one.
Change all your loops to use < rather than <= (here for the last one):
for(i=0; i<sizeof(Time)/sizeof(Time[0]); i++)
|
|
|
|
|
@Jochenn Thanks, l made the corrections and it worked.
|
|
|
|
|
#include <stdlib.h>
#include <stdio.h>
#include <strings.h>
int main(int *op[]) {
char n;
int total;
int ct = 0, oper1 = 0, oper2 = 0, oper3 = 0, i = 0;
FILE *arq1;
arq1 = fopen("Maq1.log", "r");
while (!feof(arq1)) {
n = fgetc(arq1);
if (n == "\n") {
ct++;
}
}
op = (int*) calloc(ct, sizeof(int));
if(op==0) {
printf("Não houve memoria alocada!\n");
return 0;
}
for(i=0;!feof(arq1);i++) {
fscanf(",,,%d,", &op[ct]);
}
for(i=0;i<=ct;i++) {
if(op[ct] == 1){
oper1++;
}
if(op[ct] == 2){
oper2++;
}
if(op[ct] == 3){
oper3++;
}
}
total = oper1 + oper2 + oper3;
printf("Operacao 1: %d \n Operacao 2: %d \n Operacao 3: %d \n Total: %d \n", oper1, oper2, oper3, total);
fclose(arq1);
return 0;
}
Can you guys help me on this Code? I have no idea of what is happening, but when I run the code he prints
Operacao 1: 0
Operacao 2: 0
Operacao 3: 0
Total: 0 Sorry for the bad english!
modified 13-Jan-16 15:05pm.
|
|
|
|
|
Have you tried stepping through the code using a debugger?
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
gcc -c "trabalho.c" -o "trabalho.o"
trabalho.c: In function ‘main’:
trabalho.c:22:11: warning: comparison between pointer and integer
if (n == "\n") {
^
trabalho.c:35:5: warning: format ‘%d’ expects argument of type ‘int *’, but argument 3 has type ‘int’ [-Wformat=]
fscanf(arq1, ",,,%d,", op[ct]);
^
g++ -o "trabalho.o"
Process terminated with status 0 (0 minute(s), 0 second(s))
0 error(s), 2 warning(s) (0 minute(s), 0 second(s))
Checking for existence: /home
Executing: xterm -T 'dest" (in origem)
Process terminated with status 0 (0 minute(s), 2 second(s))
When I compile the .c archive, appears just those 2 warnings
|
|
|
|
|
The three if() conditions in your for() loop are always looking at op[ct] rather than op[i] . I do not think that is your intent.
A date with the debugger, as jeron1 suggested, would have unveiled that.
"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
"You can easily judge the character of a man by how he treats those who can do nothing for him." - James D. Miles
|
|
|
|
|
Thank you! I didn't see that error of logic... --'
But still giving me the same answer :/
I think the error is when he count the lines on
char n;
while (!feof(arq1)) {
n = fgetc(arq1);
if (n == "\n") { ct++;
}
}
warning: assignment makes pointer from integer without a cast
and...
for(i=0;!feof(arq1);i++) {
fscanf(arq1, ",,,%d,", op[i]); }
format ‘%d’ expects argument of type ‘int *’, but argument 3 has type ‘int’ [-Wformat=]|
|
|
|
|
|