|
Thats is because if you pass an argument as pointer then only changes in the value of the argument will be preserved. If you want to change the pointer itself then you have to use double poitner.
int *n1 = 0;
void Fun(int **v1, int *v2)
{
*v1 = v2;
}
int main(int argc, char *argv[])
{
int *n2 = new int;
*n2 = 3;
Fun(&n1, n2);
delete n2;
return 0;
}
-Saurabh
|
|
|
|
|
Hi,
I am fighting with tab control. I can not show a dialog from resource on a tab control. I don't use MFC. I have two dialogs main with tab control and second:
///definition of my second dialog from resource file
IDD_LOADPROFILE DIALOGEX 0, 0, 87, 46
STYLE DS_SETFONT | DS_FIXEDSYS | DS_CONTROL | WS_CHILD
EXSTYLE WS_EX_CONTROLPARENT
on this message I am trying to show second dialog
case WM_INITDIALOG:
TCITEM tc;
tc.mask = TCIF_TEXT | TCIF_PARAM;
tc.pszText = "Current setting";
tc.lParam = IDD_LOADPROFILE;/// this is ID from my resource
SendDlgItemMessage(hDlg,IDC_TAB1,TCM_INSERTITEM,0,(LPARAM)&tc);
I see only the tab with label "Current settings", but I dont see second dialog.
Thank you very much.
|
|
|
|
|
I load a dialog from resource onto a WTL tab control. My dialog is:
IDD_STACKERSTATUS DIALOGEX 0, 0, 589, 442
STYLE DS_SETFONT | WS_CHILD | WS_VISIBLE
EXSTYLE WS_EX_CLIENTEDGE
Loading of the dialog onto a tab I use:
m_tabView.Create(m_tPane.m_hWnd, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, WS_EX_CLIENTEDGE);
m_StackerStatusDlg.Create(m_tabView.m_hWnd,rcDefault, NULL);
m_tabView.AddPage(m_StackerStatusDlg.m_hWnd, _T("Stacker Drive"));
Hope this is of some help.
|
|
|
|
|
Ok im trying to code a program that includes an mp3 into the exe and plays the mp3 from it, well the only problem im having and and have not been able to solve and i have been looking for 2 days now is why im having errors in my resource files im using dev C++ latest version
here is the resource file (.rc)
#include <windows.h>
#include "resource.h"
MP3_JIZZSONG RCDATA ".\\resource\\mp3\\jizz.mp3"
ICON_EXE ICON DISCARDABLE ".\\resource\\icon\\cmd.ico"
</windows.h>
here is the matching header
#define MP3_JIZZSONG 100
#define ICON_EXE 200
i have been getting this error on compile
5 N:\Documents\JizzCannon2.0\resource\resource.rc [Resource error] syntax error
if any one knows about .rs and .res files and could help that would be great thanks
-Largo Usagi
|
|
|
|
|
Looking at the documentation[^], an RCDATA needs 'raw data', enclosed by braces (which you don't have) - it can't include the contents of an external file.
I would suggest you use a user defined resource[^], as that can include the contents of a file - that's the approach I've used in the past.
|
|
|
|
|
I try to use this codes at vista but I can't run it. I use dev c++ .. this is my codes:
int main(void)
{
HKEY hKey;
char szFile[] = "D:\\xxx.exe";
RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", &hKey);
RegSetValueEx(hKey, "regeditkey", 0, REG_SZ, szFile, strlen(szFile));
RegCloseKey(hKey);
return 0;
}
I try to add my program in registry to autorun...
can you help me..
I use C programming.
|
|
|
|
|
mgbrain wrote: I try to use this codes at vista but I can't run it
OK....now, tell us, why can't you run it - what's stopping you - what's failing - help us to help you....
[edit]I presume you realise you'll need to run this program with sufficient privileges to be able to write to HKLM? Have you run it in an administrator account?[/edit]
|
|
|
|
|
I think it must run but it isn't.. when I try to use it in my program, my program runs but autorun codes is not run. I can compile my program in dev c++.. but I wanna add my program to autorun as a new key in registry.
|
|
|
|
|
Add some error checking. Check the status return values from RegOpenKey and RegSetValueEx - that should help you work out what's failing.
|
|
|
|
|
I add some error checking.. it seems having no problem..
#include<windows.h>
int main(void)
{
HKEY hKey;
char szFile[] = "D:\\prog.exe";
RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", &hKey);
RegSetValueEx(hKey, "regkey", 0, REG_SZ, szFile, strlen(szFile));
RegCloseKey(hKey);
return 0;
}
with these codes, I try to add my program in registry, I used these codes in my program's codes, but it does not work..
can you try to use these codes please..
|
|
|
|
|
mgbrain wrote: I add some error checking
Really? Can't see it - try this:
#include <Windows.h>
#include <stdio.h>
int main(void)
{
HKEY hKey;
char szFile[] = "D:\\prog.exe";
LONG status = RegOpenKey(HKEY_LOCAL_MACHINE, "Software\\Microsoft\\Windows\\CurrentVersion\\Run", &hKey);
if (ERROR_SUCCESS==status)
{
status = RegSetValueEx(hKey, "regkey", 0, REG_SZ, szFile, strlen(szFile));
if (ERROR_SUCCESS!=status)
else
{
fprintf(stderr, "RegSetValueEx failed - %d\n", (int)status);
}
RegCloseKey(hKey);
}
else
{
fprintf(stderr, "RegOpenKey failed - %d\n", (int)status);
}
return 0;
}
mgbrain wrote: can you try to use these codes please
Sorry, no - I don't have or use Windows except at work (and I'm at home currently).
|
|
|
|
|
It didn't work.. there is no error message..
|
|
|
|
|
|
I'm sorry but how can I use process monitor
|
|
|
|
|
Download it and run it? Look in the help file if you can't work it out?
|
|
|
|
|
thank you very much for your helping
|
|
|
|
|
Stuart Dootson wrote: Try using Process Monitor[^] to see exactly what your program's writing to the registry.
Regmon might be a tad simpler for the OP at this stage.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
Except that I'm not sure regmon is available to download any more - I think it and filemon were superseded by ProcMon. I agree, though - I'd rather use RegMon or FileMon
[edit]I'm wrong - you can download it[^] - but that's a version that's over 2 years old Is it compatible with Vista?[/edit]
|
|
|
|
|
What part of "your program does not have sufficient privileges" are you not getting? Your code might have worked on Windows XP and earlier, but Vista now prohibits you from accessing places in the registry and in the file system by default. You must elevate those privileges if you want this code to work with Vista.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"The brick walls are there for a reason...to stop the people who don't want it badly enough." - Randy Pausch
|
|
|
|
|
do you wanna explain what you mean, please?
|
|
|
|
|
Hi all,
I am working on a plugin that takes coordinates and sends them via socket to a receiving application. To do this, I need to package the coordinates. To make life on the receiving end easier, I want to package them as a string and send as a const char*. However, I cannot get the latitude string and the longitude string to concatenate, it just throws linker errors... any ideas what the problem is? Here is the code snippit in question:
std::stringstream sSLat;
std::stringstream sSLon;
std::string strLat;
std::string strLon;
std::string coordPack;
//package data to string
const char* sendCoords;
sSLat << lat ;
sSLon << lon;
strLat = sSLat.str();
strLon = sSLon.str();
coordPack = strLat + strLon; <---- this line seems to be causing the errors, when I comment out, it builds
sendCoords = coordPack.c_str();
Here are the errors I am getting:
1>------ Build started: Project: 2DMapPlugin, Configuration: Release Win32 ------
1>Linking...
1>2DMapPlugin.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) private: char * __thiscall stlp_std::basic_string<char,class stlp_std::char_traits<char>,class stlp_std::allocator<char> >::_M_append_fast_pos(struct stlp_std::priv::__bstr_wrapper<char,class stlp_std::char_traits<char>,class stlp_std::allocator<char> >,char *,unsigned int,unsigned int)" (__imp_?_M_append_fast_pos@?$basic_string@DV?$char_traits@D@stlp_std@@V?$allocator@D@2@@stlp_std@@AAEPADU?$__bstr_wrapper@DV?$char_traits@D@stlp_std@@V?$allocator@D@2@@priv@2@PADII@Z)
1>2DMapPlugin.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) private: char * __thiscall stlp_std::basic_string<char,class stlp_std::char_traits<char>,class stlp_std::allocator<char> >::_M_append_fast(struct stlp_std::priv::__bstr_wrapper<char,class stlp_std::char_traits<char>,class stlp_std::allocator<char> >,char *)" (__imp_?_M_append_fast@?$basic_string@DV?$char_traits@D@stlp_std@@V?$allocator@D@2@@stlp_std@@AAEPADU?$__bstr_wrapper@DV?$char_traits@D@stlp_std@@V?$allocator@D@2@@priv@2@PAD@Z)
1>2DMapPlugin.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) private: char * __thiscall stlp_std::basic_string<char,class stlp_std::char_traits<char>,class stlp_std::allocator<char> >::_M_append_fast_pos(struct stlp_std::priv::__sum_storage_elem<char,class stlp_std::char_traits<char>,class stlp_std::allocator<char> > const &,char *,unsigned int,unsigned int)" (__imp_?_M_append_fast_pos@?$basic_string@DV?$char_traits@D@stlp_std@@V?$allocator@D@2@@stlp_std@@AAEPADABU?$__sum_storage_elem@DV?$char_traits@D@stlp_std@@V?$allocator@D@2@@priv@2@PADII@Z)
1>2DMapPlugin.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) private: char * __thiscall stlp_std::basic_string<char,class stlp_std::char_traits<char>,class stlp_std::allocator<char> >::_M_append_fast(struct stlp_std::priv::__sum_storage_elem<char,class stlp_std::char_traits<char>,class stlp_std::allocator<char> > const &,char *)" (__imp_?_M_append_fast@?$basic_string@DV?$char_traits@D@stlp_std@@V?$allocator@D@2@@stlp_std@@AAEPADABU?$__sum_storage_elem@DV?$char_traits@D@stlp_std@@V?$allocator@D@2@@priv@2@PAD@Z)
1>2DMapPlugin.obj : error LNK2001: unresolved external symbol "__declspec(dllimport) private: unsigned int __thiscall stlp_std::basic_string<char,class stlp_std::char_traits<char>,class stlp_std::allocator<char> >::_M_get_additional_size(unsigned int,struct stlp_std::__true_type const &)const " (__imp_?_M_get_additional_size@?$basic_string@DV?$char_traits@D@stlp_std@@V?$allocator@D@2@@stlp_std@@ABEIIABU__true_type@2@@Z)
1>C:\Documents and Settings\lundg\My Documents\Visual Studio 2005\Projects\2DMapPlugin\Release\2DMapPlugin.dll : fatal error LNK1120: 5 unresolved externals
1>Build log was saved at "file://c:\Documents and Settings\lundg\My Documents\Visual Studio 2005\Projects\2DMapPlugin\2DMapPlugin\Release\BuildLog.htm"
1>2DMapPlugin - 6 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Any help you can give will be appreciated!
Thanks!
modified on Thursday, February 5, 2009 1:27 PM
|
|
|
|
|
What if you do instead of this:
coordPack = strLat + strLon;
this:
coordPack = strLat;
coordPack += strLon;
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Life: great graphics, but the gameplay sux. <
|
|
|
|
|
That's a linker error - for some reason, your build is not pulling in the C++ run-time library by the look of it.
Looking at the namespace in the linker errors - "stlp_std " - are you using STLPort rather than Microsoft's STL implementation? If so, you need to link in the STLPort import libraries before the Microsoft ones.
|
|
|
|
|
Thanks for the help guys! I was using std instead of stlp_std, so I made the adjustment, and now it compiles fine!
I appreciate it!
|
|
|
|
|
Hi,
I can not find out how to read what is in a VARIANT, which is the result of calling a method GetAllProperties. The doc of this method only specifies that a VARIANT is returned. It should contain some kind of strings. I tried this :
VARIANT names;
_variant_t v1;
VARTYPE vtype;
long ix;
...
x->GetAllProperties(&names);
if (V_ISARRAY(&names)) {
SafeArrayGetVartype(names.parray,&vtype);
// this returns 0x0800 in vtype, so I assume it is an array of _variant_t !!!
for (ix=0;ix<nprops;ix++) {
SafeArrayGetElement(names.parray,&ix,&v1);
_bstr_t s1(v1);
printf("name=%s\n",(char *)s1);
}
}
But this ends in an exception during the statement "_bstr_t s1(v1);"
What do I do wrong ???
Linde Ackermans
|
|
|
|
|